Sunday, January 6, 2019

Salesforce Trailhead : Platform Developer I Certification Maintenance (Winter '19)

Unit : Platform Developer I Certification Maintenance (Winter '19)

UNIT : Understand New and Updated Apex Methods, Exceptions, and Interfaces

1. Which method of the DescribeSObjectResult class allows you to access record types by their developer name?
A. getRecordTypeInfos()
B. getRecordTypeInfosById()
C. getRecordTypeInfosByName()
D. getRecordTypeInfosByDeveloperName()

2. Which Apex class includes new methods to verify digital and HMAC signatures?
A. System.Auth
B. System.Crypto
C. System.Approval
D. Schema.Signature 

UNIT : Learn What's New for Platform Developers

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 a Named Credential.
B. Use System.UserInfo.getSessionId().
C. Set the endpoint to URL.getOrgDomainUrl().
D. Session IDs are no longer required when My Domain is enabled.

2. Which annotation allows a developer to make the result of an Apex method storable for Lightning components?
A. @AuraStorable
B. @AuraCacheable
C. @AuraEnabled(storable=true)
D. @AuraEnabled(cacheable=true)

3. Which merge field allows you to isolate untrusted third-party content with tag in Visualforce?
A. $Resource
B. $SecureResource
C. $IFrameResource
D. $Page.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. InstalledPackage
B. PackageDependency
C. UnlockedPackageInfo
D. SubscriberPackageVersion

UNIT : Work with the Lightning Map Component and Apex Inherited Sharing

TASK : Use the new Winter ’19 features, lightning:map component and Apex inherited sharing

Create a Lightning component that references the new lightning:map component and include it in a custom Account record page. The component will use an Apex controller that applies the Inherited Sharing keyword to ensure reusability across multiple applications.
Using the new information you created for Out and About Communications, implement the following to complete this challenge.
πŸ‘‰Copy the helper class code block, TowerMapUtilClass, from above and modify it so the sharing rules are enforced based on the sharing setting of the calling class.
πŸ‘‰Copy the controller code block, TowerMapControllerClass, from above and modify it so the sharing rules are enforced.
πŸ‘‰Copy and modify the Lightning component code above to implement a lightning:map component named Towermap. Replace the with your code. Your code should pass the value of v.mapMarkers to the mapMarkers attribute, pass the value of v.markersTitle to the markersTitle attribute, and set the zoomLevel attribute to 5.
πŸ‘‰Copy and paste the controller and helper code blocks above to create controller and helper functions to pull all Tower locations from the server.
πŸ‘‰To view your map, you can use Lightning App Builder to create a standalone one-column app page named Towers and add it to the Lightning Experience App Launcher. More experienced developers can chose another method to expose the component, if desired.

Steps To Follow :-
Step 1 : Create Custom Object ie..., Tower
Label : Tower
Plural Label : Towers
Step 2 : Create a New Custom Field in Tower Object.
πŸ‘‰1. Field Label: State
Type: Master-Detail
Related To : Account
Field Name: State
Child Relationship Name: Towers
πŸ‘‰2. Field Label: Tower Location
Field Name: Tower_Location
Type: Geolocation
Latitude and Longitude Display Notation: Decimal
Decimal Places: 6
Step 3 : Create Sample Records as Follows :
πŸ‘‰ Create two new Account records to represent the regions (only the Name field is required).
1. Utah
2. Idaho
πŸ‘‰ Create four new Tower records
1. Name: Lightning Ridge
State: Utah
Latitude: 40.490684
Longitude: -110.908727
2. Name: Craters
State: Idaho
Latitude: 43.555375
Longitude: -113.70069
3. Name: Nuckols
State: Idaho
Latitude: 47.516694
Longitude: -115.939163
4. Name: Rainbow
State: Utah
Latitude: 37.060663
Longitude: -110.975708

Step 4 : Apex Class - TowerMapUtilClass
 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);  
Step 5 : Apex Class - TowerMapControllerClass
 public inherited sharing class TowerMapControllerClass {  
    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;  
Step 6 : Lightning Component : 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)}" >  
     mapMarkers="{! v.mapMarkers }"  
     markersTitle = "{!v.markersTitle}"  
     zoomLevel="5" />  
Step 7 : Controller : TowermapController.js
    handleInit: function (component, event, helper) {  
      helper.initHelper(component, event, helper);  
Step 8 : Helper : 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];  
             '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);