Saturday 12 January 2019

Platform Developer I Certification Maintenance (Winter '19)


1. Which method of the DescribeSObjectResult class allows you to access record types by their developer name?
A.getRecordTypeInfoByDeveloperName()

2. Which Apex class includes new methods to verify digital and HMAC signatures?
A. system.cypto


1.Your org has My Domain enabled. What is the most efficient method to obtain a valid session ID to make an HTTP callout from asynchronous Apex code to Salesforce APIs?
A.Use System.UserInfo.getSessionId().

2.Which annotation allows a developer to make the result of an Apex method storable for Lightning components?

A. @AuraEnabled(cacheable=true)

3.Which merge field allows you to isolate untrusted third-party content with <apex:iframe> tag in Visualforce?

A. $IFrameResource

4.Prior to installing an unlocked package, which object should a developer query using the Tooling API to list the packages it depends on?

A. SubscriberPackageVersion

TowerMapControllerClass.apxc
--------------------------------------
public inherited sharing class TowerMapControllerClass {
     @AuraEnabled
     public static List<Tower__c> getAllTowers() {
          String theObject = 'Tower__c';
          List<String> theFields = new List<String>{'Id', 'Name', 'State__r.Name', 'Tower_Location__Latitude__s', 'Tower_Location__Longitude__s'};
          String theFilter = '';
          String sortField = 'Name';
          String sortOrder = 'ASC';
          List<Tower__c> allTowers = TowerMapUtilClass.queryObjects(theObject, theFields, theFilter, sortField, sortOrder);
          return allTowers;
     }
}

TowerMapUtilClass.apxc
-------------------------------
public inherited sharing class TowerMapUtilClass {
     public static List<sObject> queryObjects(String theObject, List<String> theFields, String theFilter, String sortField, String sortOrder) {
          String theQuery = 'SELECT ' + string.join(theFields, ',');
          theQuery += ' FROM ' + theObject;
          if(!String.isEmpty(theFilter)) {
               theQuery += ' WHERE ' + theFilter;
          }
          if(!String.isEmpty(sortField)) {
               theQuery += ' ORDER BY ' + sortField;
               if(!String.isEmpty(sortOrder)) {
                    theQuery += ' ' + sortOrder;
               }
          }
          return database.query(theQuery);
     }
}

Towermap.cmp
------------------
<aura:component implements="flexipage:availableForAllPageTypes" controller="TowerMapControllerClass" access="global" >
     <aura:attribute name="mapMarkers" type="Object" access="PRIVATE" />
     <aura:attribute name="markersTitle" type="String" access="PRIVATE" />
     <aura:handler name="init" value="{!this}" action="{!c.handleInit}"/>
     <aura:if isTrue="{!!empty(v.mapMarkers)}" >
          <!-- Create lightning:map here -->
       
         &lt;lightning:map
        mapMarkers="{! v.mapMarkers }"
        markersTitle = "{!v.markersTitle}"
        zoomLevel="5" />
     </aura:if>
</aura:component>

TowermapHelper.js
-----------------------
({
     initHelper : function(component, event, helper) {
          helper.utilSetMarkers(component, event, helper);
     },
     utilSetMarkers : function(component, event, helper) {
          let action = component.get("c.getAllTowers");
          action.setCallback(this, function(response) {
               const data = response.getReturnValue();
               const dataSize = data.length;
               let markers = [];
               for(let i=0; i < dataSize; i += 1) {
                    const Tower = data[i];
                    markers.push({
                        'location': {
                             'Latitude' : Tower.Tower_Location__Latitude__s,
                             'Longitude' : Tower.Tower_Location__Longitude__s
                        },
                        'icon': 'utility:Tower',
                        'title' : Tower.Name,
                        'description' : Tower.Name + ' Tower Location at ' + Tower.State__r.Name
                   });
               }
               component.set('v.markersTitle', 'Out and About Communications Tower Locations');
               component.set('v.mapMarkers', markers);
          });
          $A.enqueueAction(action);
     }
})

No comments: