Monday, April 29, 2019

Platform Developer I Certification Maintenance (Spring '19)

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

UNIT : Learn What’s New for Platform Developers in Spring ’19:-

1. Which Apex interface can be implemented to allow My Domain users to log in with something other than their username and password?
A. Auth.AuthToken

B. Auth.VerificationMethod
C. Auth.LoginDiscoveryHandler
D. Auth.MyDomainLoginDiscoveryHandler

2. With Spring '19, which method returns a list of OrgLimit instances used to investigate limits and their names, current value, and maximum value?
A. getAll() from the System.OrgLimit Class
B. getAll() from the System.OrgLimits Class
C. getInstances() from the System.OrgLimit Class
D. getInstances() from the System.OrgLimits Class

3. With Spring '19, which properties of an unhandled Apex exception are available in Event Monitoring log files?
A. Static variable state and stack trace
B. Exception type, name, and static variable state
C. Stack trace, user's location, and exception type
D. Exception message, exception type name, and stack trace

4. Which field of the SandboxInfo object is a reference to the ID of the SandboxInfo that served as the source org for a cloned sandbox?
A. SourceId
B. TemplateId
C. SandboxName
D. SandboxInfoId

5. You created a custom metadata type to handle your company's warranty policy. The custom metadata type's label is WarrantyRule. For it, you created a custom field labeled Warranty and a metadata record labeled Gold. What is the correct syntax to reference the value stored in the Gold metadata record?
A. $WarrantyRule.Gold.Warranty__c
B. $WarrantyRule__mdt.Gold.Warranty
C. $CustomMetadata.WarrantyRule.Gold.Warranty
D. $CustomMetadata.WarrantyRule__mdt.Gold.Warranty__c

Get Ready for the Hands-on Challenge:-


In the hands-on challenge below, you’ll have an opportunity to work with these new security settings and use the new WITH SECURITY_ENFORCED clause in SOQL queries run from Apex to simplify your code. But before we get started, a bit of setup is required. 


Our business goal is to ensure that only system administrators have access to sensitive customer information, and that other users cannot invoke our APIs that handle sensitive data. To ensure that our code is generally safe, we need to make runtime checks of field- and object-level security. As developers, we need to specifically ensure our code respects admin-defined security constraints.

Launch the org you’ll use for the hands-on challenge, then do the following.

Create a new custom field on the Contact object to establish a field that contains sensitive information about the secret keys of our customers.
Field Label: Secret Key
Type: Text
Field Name: Secret_Key
 @RestResource(urlMapping='/secureApexRest')  
 global with sharing class SecureApexRest {  
   @HttpGet  
   global static Contact doGet(){  
     Id recordId = RestContext.request.params.get('id');  
     Contact result;  
     List<Contact> results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];  
     if (!results.isEmpty()) {  
        result = results[0];  
      }  
      else{  
       throw new QueryException('You don\'t have access to all contact fields required to use this API');  
     }  
     return result;  
   }  
    public class QueryException extends Exception{}  
 }  

Sunday, April 28, 2019

Platform App Builder Certification Maintenance (Spring '19)

Unit : Platform App Builder Certification Maintenance (Spring '19)

UNIT : Learn What's New For App Builders:-

1. Which permission does an app builder need to access the Flow Builder?
A. Flow Manager
B. Author Apex
C. Manage Flow
D. Lightning Experience User

2. Where can an app builder change the layout of a Lightning page?
A. Page Layout
B. Properties
C. Page Navigator
D. App Options

3. An account team is no longer needed. What action can the account owner take to remove the entire team?
A. Create a custom action.
B. Use Transfer Account Team.
C. Remove all members manually.
D. Use Remove All Members.

4. Which language can an app builder use to build Lightning web components?
A. CSS
B. HTML
C. JQuery
D. Visualforce

5. Which relative set of date/time fields can an app builder specify in a macro when it is run?
A. Now, Time, Date
B. Today, DateTime, Date
C. Time, Date, DateTime
D. DateTime, Time, Today

UNIT : Get Hands-on with Customized Home Pages and Components:-

Now you can make your Lightning pages more dynamic by configuring home page components.
You've been given a requirement to make the Sales app home page specific for the Sales team. Build out a custom Lightning home page for the Sales app.
👉Launch a new Trailhead Playground
If you see an error when attempting to launch the playground, wait a few minutes and try again. It could take up to 15 minutes for the Playground to load.
👉Create a new Lightning page:
Page type: Home Page
Label: Sales Home Page
Template: Standard Home Page
👉Add the following components to the page:
Rich Text
Chatter Feed
Assistant
Today's Events
Today's Tasks
👉In the Rich Text component:
Add the text: Welcome!
Set font to: Salesforce Sans
👉On the Rich Text component, add a filter to set component visibility:
Field: Permissions > Standard Permission > Lightning Experience User
Operator: Equal
Value: True
👉Save and activate the page for all users.

👉Assign the page as the org default.

Administrator Certification Maintenance (Spring '19)

Unit : Administrator Certification Maintenance (Spring '19)

UNIT : Learn What's New in Spring '19:-

1. On which set of objects can an administrator customise the Stage Setup Flow?
A. Leads and cases
B. Leads and opportunities
C. Account and contacts
D. Campaigns and campaign members

2. How many blocks are available in joined reports?
A. 2
B. 3
C. 5
D. 8

3. An account team is no longer needed. How can the account owner remove the entire team?
A. Create a custom action
B. Use Transfer Account Team
C. Create a Delete Team process builder
D. Use Remove All Members

4. Which set of actions can an administrator take with subtab options in Console?
A. Refresh, customize, promote
B. Promote, publish, close
C. Promote, refresh, delete
D. Refresh, customize, publish

5. For which object can an administrator grant data sharing rules within workflows?
A. Tasks
B. Opportunities
C. Products
D. Contracts

6. Which relative date/time can an administrator specify in a macro when it is run?
A. Months from now
B. Years from today
C. Hours from now
D. Minutes from today

UNIT : Get Hands-on with Lightning Pages:-
Don’t like the layout of a Lightning page? Did your business needs change? Now with a few clicks, you can swap a Lightning page’s template.
You've been given a requirement to change the Account Record Page Lightning template.
👉Launch a new Trailhead Playground
If you see an error when attempting to launch the playground, wait a few minutes and try again. It could take up to 15 minutes for the Playground to load.
👉Create a new Lightning page:
To create a Lightning Page, Follow below Steps:-
Step 1 : Setup - Quick Findbox - Search for Lightning App Builder
Step 2 : Click on New 
Type: Record Page
Label: Account Management
Object: Account
Template: click Clone Salesforce Default Page, and then select Account Record Page Default
Click Finish

👉Change the Page Template to Header, Subheader, Left Sidebar
Leave template mapping as is and click Done

👉Add the following standard components to your page:-
Topics
Recent Items
👉Save and Activate; assign page as the Org Default

Saturday, February 23, 2019

Asynchronous Apex

Asynchronous Processing Basics

1. What is a key benefits of asynchronous processing?
A. Higher governor and execution limits
B. Unlimited number of external callouts
C. Override organization-wide sharing defaults
D. Enabling turbo mode for transactional processing
2. Batch Apex is typically the best type of asynchronous processing when you want to:
A. Make a callout to a web service when a user updates a record.
B. Schedule a task to run on a weekly basis.
C. Update all records in your org.
D. Send a rickroll email to a contact

Use Future Methods

Create an Apex class that uses the @future annotation to update Account records.
Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
 public class AccountProcessor {  
   @future  
   public static void countContacts(Set<Id> conId)  
   {  
     List<Account> accList = [SELECT ID, Name, Number_Of_Contacts__c, (SELECT ID From Contacts)FROM Account WHERE ID IN :conId];  
     for(Account acc : accList)  
     {  
       List<Contact> conList = acc.Contacts;  
       acc.Number_Of_Contacts__c = conList.Size();  
     }  
     update accList;  
   }  
 }  
Test Class :-
 @isTest  
 public class AccountProcessorTest {  
      public static testMethod void createAccount()  
   {  
     Account acc = New Account();  
     acc.Name = 'Test-Account';  
     Insert acc;  
     Contact con = New Contact();  
     con.FirstName = 'Test-FirstName-Contact';  
     con.LastName = 'Test-LastName-Contact';  
     con.AccountId = acc.Id;  
     Insert con;  
     Set<Id> accId = new Set<Id>();  
     accId.add(acc.Id);  
     Test.startTest();  
          AccountProcessor.countContacts(accId);  
     Test.stopTest();  
     Account accList = [SELECT Number_of_Contacts__c FROM Account where id = : acc.Id LIMIT 1];  
     System.assertEquals(accList.Number_of_Contacts__c, 1);  
   }  
 }  

Use Batch Apex

Create an Apex class that uses Batch Apex to update Lead records.
Create an Apex class that implements the Database.Batchable interface to update all Lead records in the org with a specific LeadSource. Write unit tests that achieve 100% code coverage for the class.
 global class LeadProcessor implements  Database.Batchable<Sobject>   
 {  
   global Database.QueryLocator start(Database.BatchableContext bc)   
   {  
     return Database.getQueryLocator([Select LeadSource From Lead ]);  
   }  
   global void execute(Database.BatchableContext bc, List<Lead> scope)  
   {  
       for (Lead Leads : scope)   
       {  
         Leads.LeadSource = 'Dreamforce';  
       }  
     update scope;  
   }    
   global void finish(Database.BatchableContext bc){  }    
 }  
Test Class :-
 @isTest   
 public class LeadProcessorTest   
 {  
   static testMethod void testMethod1()   
   {  
     List<Lead> lstLead = new List<Lead>();  
     for(Integer i=0 ;i <200;i++)  
     {  
       Lead led = new Lead();  
       led.FirstName ='FirstName';  
       led.LastName ='LastName'+i;  
       led.Company ='demo'+i;  
       lstLead.add(led);  
     }  
     insert lstLead;  
     Test.startTest();  
       LeadProcessor obj = new LeadProcessor();  
       DataBase.executeBatch(obj);   
     Test.stopTest();  
   }  
 }  

Control Processes with Queueable Apex

Create an Queueable Apex class that inserts Contacts for Accounts.
Create a Queueable Apex class that inserts the same Contact for each Account for a specific state. Write unit tests that achieve 100% code coverage for the class.
 public class AddPrimaryContact implements Queueable {  
   public Contact con;  
   public String state;  
      public AddPrimaryContact(Contact con, String state)  
   {  
     this.con = con;  
     this.state = state;  
   }  
   public void execute(QueueableContext qc)  
   {  
     List<Account> accList = [SELECT Id, Name, BillingState FROM Account WHERE Account.BillingState =: this.state Limit 200];  
     List<Contact> newContact = new List<Contact>();  
     for(Account acc : accList)  
     {  
       Contact con = new Contact();  
       con = this.con.clone(false, false, false, false);  
       con.AccountId = acc.Id;  
       newContact.add(con);  
     }  
     insert newContact;  
   }  
 }  
Test Class :-
 @isTest  
 public class AddPrimaryContactTest {  
 @testSetup  
 static void setup() {  
      List<Account> insertAccount = new List<Account>();  
      for(integer i=0; i<=100; i++) {  
      if(i <=50) {  
      insertAccount.add(new Account(Name='Acc'+i, BillingState = 'NY'));  
      }   
     else {  
           insertAccount.add(new Account(Name='Acc'+i, BillingState = 'CA'));  
           }  
      }  
      insert insertAccount;  
      }  
 static testMethod void testAddPrimaryContact() {  
   Contact con = new Contact(LastName = 'LastName');  
   AddPrimaryContact addPC = new AddPrimaryContact(con, 'CA');  
   Test.startTest();  
   system.enqueueJob(addPC);  
   Test.stopTest();  
      system.assertEquals(50, [SELECT count() FROM Contact]);  
      }  
 }  

Schedule Jobs Using Apex Scheduler

Create an Apex class that uses Scheduled Apex to update Lead records.
Create an Apex class that implements the Schedulable interface to update Lead records with a specific LeadSource. Write unit tests that achieve 100% code coverage for the class. This is very similar to what you did for Batch Apex.
 global class DailyLeadProcessor implements Schedulable{  
   global void execute(SchedulableContext sc){  
     List<Lead> lstOfLead = [SELECT Id FROM Lead WHERE LeadSource = null LIMIT 200];  
     List<Lead> lstOfUpdatedLead = new List<Lead>();  
     if(!lstOfLead.isEmpty()){  
       for(Lead ld : lstOfLead){  
         ld.LeadSource = 'Dreamforce';  
         lstOfUpdatedLead.add(ld);  
       }  
       UPDATE lstOfUpdatedLead;  
     }      
   }  
 }  
Test Class :-
 @isTest  
 private class DailyLeadProcessorTest{  
   @testSetup  
   static void setup(){  
     List<Lead> listOfLead = new List<Lead>();  
     for(Integer i = 1; i <= 200; i++){  
       Lead ld = new Lead(Company = 'Comp' + i ,LastName = 'LN'+i, Status = 'Working - Contacted');  
       listOfLead.add(ld);  
     }  
     Insert listOfLead;  
   }  
   static testmethod void testDailyLeadProcessorScheduledJob(){  
     String sch = '0 5 12 * * ?';  
     Test.startTest();  
     String jobId = System.schedule('ScheduledApexTest', sch, new DailyLeadProcessor());  
     List<Lead> listOfLead = [SELECT Id FROM Lead WHERE LeadSource = null LIMIT 200];  
     System.assertEquals(200, listOfLead.size());  
     Test.stopTest();  
   }  
 }  

Monitor Asynchronous Apex

1. What type of jobs do not show up in the Apex Flex Queue.
A. Future Method Jobs
B. Batch Apex Jobs
C. Queueable Apex Jobs
D. Scheduled Apex Jobs
2. Which statement is true regarding the Flex Queue.
A. You can submit up to 200 batch jobs for execution.
B. Jobs are processed first-in first-out.
C. Jobs can only be scheduled during Taco Tuesdays.
D. Jobs are executed depending upon user license

Sunday, January 6, 2019

Salesforce Trailhead : Platform App Builder Certification Maintenance (Winter '19)

Unit : Platform App Builder Certification Maintenance (Winter '19)


UNIT : Learn What’s New for App Builders

1. Which behavior is true when using the 'Deploy processes and flows as active' feature?
A. Apex tests must cover 75% of all active Processes and autolaunched Flows.
B. Pre-existing Processes and autolaunched Flows are marked as Inactive.
C. The Change Set must include a Permission Set that enables the 'deploy processes and flows as active' feature.
D. The Change Set must include a Permission Set that activates the Processes and Flows.
2. How should an App Builder ensure that Users are able to see Survey responses?
A. Subscribe Users to a Survey with Responses report.
B. Schedule a nightly Apex job to compile Survey statistics.
C. Grant Users See All Data on the Survey object.
D. Grant access to the Survey object then direct users to the Survey Invitations related list.

3. How can a user share the contents of a Salesforce Folder with customers in Lightning?
A. Create a Content Pack.
B. Create a public link to a Shared Folder.
C. Create a ZIP file containing multiple Files.
D. Create a Public Knowledge Base.

4. How can an App Builder configure a Guided Action to be mandatory on a record?
A. Mark the Guided Action Component as Required on the record page.
B. Create a Validation Rule for the record on which the Guided Action is run.
C. Set the Is Mandatory field in a Process that launches the Flow.
D. Set the Is Mandatory Flow public variable in the Flow.

UNIT : Get Hands-on with Lightning Pages

TASK : Create a Lightning app with a filtered standard component

You've been given a requirement to create a new app with a filtered display of leads on a standard list view component, based on user permissions.
To get started:
If needed, complete the Lightning App Builder module to learn more about creating Lightning pages.
👉Create a new Lightning app page:
Page Type: App Page
Label: App Filtered View
Layout: One Column
👉Add the following standard components to your page:
Chatter Feed
List View
👉Configure the List View standard component as follows:
Object: Lead
Filter: All Open Leads
Number of Records to Display: 10
👉Add a filter to set component visibility for the List View standard component to users with specific permissions:
Field: Permissions ↦Standard Permissions ↦Manage Leads
Operator: Equal
Value: True
👉Activate the page for all users.
👉Add the page to the Sales app.

Steps To Follow :-
Step 1 : Click on Setup, In Quick find box search for Lightning App Builder.
Step 2 : Click on NEW
Step 3 : Select APP Page, Click on Next
Label : App Filtered View, Click on Next ↦ select One Column Layout ↦ Finish.
Step 4 : 👉Add the following standard components to your page:
Chatter Feed
List View
Step 5 : Configure the List View standard component as follows:
Object: Lead
Filter: All Open Leads
Number of Records to Display: 10
Step 6 : 👉Add a filter to set component visibility for the List View standard component to users with specific permissions:

Field: Permissions ↦Standard Permissions ↦Manage Leads
Operator: Equal
Value: True

Step 7 : Save & Activate
Step 8 : 👉Activate the page for all users.

Step 9 : 👉Add the page to the Sales app.

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 {  
    @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;  
    }  
 }  
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)}" >  
      <lightning:map   
     mapMarkers="{! v.mapMarkers }"  
     markersTitle = "{!v.markersTitle}"  
     zoomLevel="5" />  
    </aura:if>  
 </aura:component>  
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];  
           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);  
    }  
 })