Friday, May 3, 2019

Platform Developer I Certification Maintenance (Spring '19) Answer

Platform Developer I Certification Maintenance (Spring '19) Answer

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:-

Challenge

Practice simplifying object- and field-level security checks with new Spring ’19 in Apex code


Solution

Challenge step 1: Create the Secret Key custom text field on the Contact object as specified in the Get Ready for the Hands-on Challenge section.


For this step, I hope you already created the field as per trailhead steps. If not follow the below.

Login to salesforce lightning

Click on the Gear icon and click the setup

Click Object manager menu item and search for Contact object, In the contact object go to Fields and relationships sub tab

Click the New button and enter below details

Choose Field type as Text and click Next button 


In the next screen, fill the details as mentioned below and click Next button

Field Label: Secret Key, Field Name: Secret_Key and Length: 255


In the next screen, Uncheck the Visible box for the “Standard User” profile when defining field-level security and click Next 

Click save



Challenge step 2: Create a new Apex class named SecureApexRest.

Click the Gear icon at the top right corner of the salesforce application and click Developer console option


In the Developer console window, click File > New > Apex class > Enter the class name SecureApexRest, click Ok



Challenge step 3: Copy and paste the SecureApexRest code provided above. This code is already secured with conventional field- and object-level access checks.


You can copy and paste the below-mentioned code in your newly created class

@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        try{
            List<Contact> results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];
            if (!results.isEmpty()) {
                result = results[0];
            }
        }catch(QueryException QE){
            throw new SecurityException('You don\'t have access to all contact fields required to use this API');
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}


Save the apex class.

No changes required for further steps of the challenge. Check the solution by clicking on Check challenge button in the trailhead page. 

2 comments:

  1. Selecting DumpsTool Adobe Exams for my guidance proved worth every penny!

    ReplyDelete
  2. Prepare4Test the best and reliable platform where you can get accurate AD0-E200 question dumps which will assist you in passing your Adobe Analytics Architect Master Exam fast.

    ReplyDelete