PDII Salesforce Certified Platform Developer II ( Plat-Dev-301 ) Questions and Answers
A developer built an Aura component for guests to self-register upon arrival at a front desk kiosk. Now the developer needs to create a component for the utility tray to alert users whenever a guest arrives at the front desk. What should be used?
The test method calls an @future method that increments a value. The assertion is failing because the value equals 0. What is the optimal way to fix this?
Java
@isTest
static void testIncrement() {
Account acct = new Account(Name = ' Test ' , Number_Of_Times_Viewed__c = 0);
insert acct;
AuditUtil.incrementViewed(acct.Id); // This is the @future method
Account acctAfter = [SELECT Number_Of_Times_Viewed__c FROM Account WHERE Id = :acct.Id][0] ;
System.assertEquals(1, acctAfter.Number_Of_Times_Viewed__c);
}
Universal Containers is leading a development team that follows the source-driven development approach in Salesforce. As part of their continuous integration and delivery (CI/CD) process, they need to automatically deploy changes to multiple environments, including sandbox and production. Which mechanism or tool would best support their CI/CD pipeline in source-driven development?
A developer is writing code that requires making callouts to an external web service. Which scenario necessitates that the callout be made in an asynchronous method?
A company has reference data stored in multiple custom metadata records that represent default information and delete behavior for certain geographic regions. When a contact is inserted, the default information should be set. Additionally, if a user attempts to delete a contact that belongs to a flagged region, the user must get an error message. Depending on company personnel resources, what are two ways to automate this? 19
Universal Containers implements a private sharing model for Convention_Attendee__c. A lookup field Event_Reviewer__c was created. Management wants the event reviewer to automatically gain Read/Write access to every record they are assigned to. What is the best approach?
A company wants to run different logic based on an Opportunity ' s record type. Which code segment handles this request and follows best practices?
A Lightning web component exists in the system and displays information about the record in context as a modal. Salesforce administrators need to use this component within the Lightning App Builder. Which two settings should the developer configure within the xml resource file?
A developer needs to send Account records to an external system for backup purposes. The process must take a snapshot of Accounts as they are saved and then make a callout to a RESTful web service. The web service can only receive, at most, one record per call. What should a developer do to implement these requirements?
A company has an Apex process that makes multiple extensive database operations and web service callouts. The database processes and web services can take a long time to run and must be run sequentially. How should the developer write this Apex code without running into governor limits and system limitations? 123
An Apex trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. A developer is tasked with preventing Contract records from being created when mass loading historical Opportunities, but the daily users still need the logic to fire. What is the most extendable way to update the Apex trigger to accomplish this?
Universal Containers (UC) has enabled the translation workbench and has translated picklist values. UC has a custom multi-select picklist field, Products__c, on the Account object that allows sales reps to specify which of UC ' s products an Account already has. A developer is tasked with writing an Apex method that retrieves Account records, including the Products__c field. What should the developer do to ensure the value of Products__c is in the current user ' s language? 40
public class searchFeature {
public static List < List < object > > searchRecords(string searchquery) {
return [FIND :searchquery IN ALL FIELDS RETURNING Account, Opportunity, Lead];
}
}
// Test Class
@isTest
private class searchFeature_Test {
@TestSetup
private static void makeData() {
//insert opportunities, accounts and lead
}
private static searchRecords_Test() {
List < List < object > > records = searchFeature.searchRecords( ' Test ' );
System.assertNotEquals(records.size(),0);
}
}
However, when the test runs, no data is returned and the assertion fails. Which edit should the developer make to ensure the test class runs successfully?
Refer to the component code and requirements below:
HTML
< lightning:layout multipleRows= " true " >
< lightning:layoutItem size= " 12 " > {!v.account.Name} < /lightning:layoutItem >
< lightning:layoutItem size= " 12 " > {!v.account.AccountNumber} < /lightning:layoutItem >
< lightning:layoutItem size= " 12 " > {!v.account.Industry} < /lightning:layoutItem >
< /lightning:layout >
Requirements:
For mobile devices, the information should display in three rows .
For desktops and tablets, the information should display in a single row .
Requirement 2 is not displaying as desired. Which option has the correct component code to meet the requirements for desktops an 7 d tablets?
A developer created a class that implements the Queueable Interface, as follows:
Java
public class without sharing OrderQueueableJob implements Queueable {
public void execute(QueueableContext context) {
// implementation logic
System.enqueueJob(new FollowUpJob());
}
}
As part of the deployment process, the developer is asked to create a corresponding test class. Which two actions should the developer take to successfully execute the test class? 1
Refer to the code below:
Lightning Web Component JS file
JavaScript
import {LightningElement} from ' lwc ' ;
import serverEcho from ' @salesforce/apex/SimpleServerSideController.serverEcho ' ;
export default class Helloworld extends LightningElement {
firstName = ' world ' ;
handleClick() {
serverEcho({
firstName: this.firstName
})
.then((result) = > {
alert( ' From server: ' + result);
})
.catch((error) = > {
console.error(error);
});
}
}
Apex Controller
Java
public with sharing class SimpleServerSideController {
@AuraEnabled
public static String serverEcho(sObject firstName) {
String firstNameStr = (String)firstName.get( ' firstName ' );
return ( ' Hello from the server, ' + firstNameStr);
}
}
Given the code above, which two changes need to be made in the Apex Controller for the code to work?
Universal Containers needs to integrate with their own, existing, internal custom web application. The web application accepts JSON payloads, resizes product images, and sends the resized images back to Salesforce. What should the developer use to implement this integration?
Universal Containers wants to use a Customer Community with Customer Community Plus licenses. UC uses a Private sharing model for External users. One of the requirements is to allow certain community users within the same Account hierarchy to see several departments ' containers, based on a custom junction object that relates the Contact to the various Account records. Which solution solves these requirements?
A developer wrote an Apex class to make several callouts to an external system. If the URLs used in these callouts will change often, which feature should the developer use to minimize changes needed to the Apex class?
Business rules require a Contact to always be created when a new Account is created. What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?
A developer sees test failures in the sandbox but not in production. No code or metadata changes have been actively made to either environment since the sandbox was created. Which consideration should be checked to resolve the issue?
The CalloutUtil.makeRestCallout fails with a ' You have uncommitted work pending. Please commit or rollback before calling out ' error. What should be done to address the problem?
Java
public void updateAndMakeCallout(Map < Id, Request__c > regs, Map < Id, Request_Line__c > regLines) {
Savepoint sp = Database.setSavepoint();
try {
insert regs.values();
insert regLines.values();
HttpResponse response = CalloutUtil.makeRestCallout(regs.keySet(), regLines.keySet());
} catch (Exception e) {
Database.rollback(sp);
}
}
A developer is building a Lightning web component that retrieves data from Salesforce and assigns it to the record property:
JavaScript
import { LightningElement, api, wire } from ' lwc ' ;
import { getRecord } from ' lightning/uiRecordApi ' ;
export default class Record extends LightningElement {
@api fields;
@api recordId;
record;
}
What must be done in the component to get the data from Salesforce?
Which three actions must be completed in a Lightning web component for a JavaScript file in a static resource to be loaded?
Which two queries are selective SOQL queries and can be used for a large data set of 200,000 Account records?
Universal Containers uses a custom Lightning page to provide a mechanism to perform a step-by-step wizard search for Accounts. One of the steps in the wizard is to allow the user to input text into a text field, ERP_Number__c, that is then used in a query to find matching Accounts.
Java
erpNumber = erpNumber + ' % ' ;
List < Account > accounts = [SELECT Id, Name FROM Account WHERE ERP_Number__c LIKE :erpNumber];
A developer receives the exception ' SOQL query not selective enough ' . Which step should be taken to resolve the issue?
A developer has business logic in a trigger that flags high-value opportunities. There is a new requirement to also display high value opportunities in a Lightning web component. Which two steps should the developer take to meet these business requirements, and also prevent the business logic that identifies high-value opportunities from being repeated in more than one place?
A large company uses Salesforce across several departments. Each department has its own Salesforce Administrator. It was agreed that each Administrator would have their own sandbox in which to test changes. Recently, users notice that fields that were recently added for one department suddenly disappear without warning. Which two statements are true regarding these issues and resolution? 3637
Java
trigger AssignOwnerByRegion on Account ( before insert, before update ) {
List < Account > accountList = new List < Account > ();
for( Account anAccount : trigger.new ) {
Region__c theRegion = [
SELECT Id, Name, Region_Manager__c
FROM Region__c
WHERE Name = :anAccount.Region_Name__c
];
anAccount.OwnerId = theRegion.Region_Manager__c;
accountList.add( anAccount );
}
update accountList;
}
Consider the above trigger. Which two changes should a developer make in this trigger to adhere to best practices? 30
Universal Containers is using a custom Salesforce application to manage customer support cases. The support team needs to collaborate with external partners to resolve certain cases. However, they want to control the visibility and access to the cases shared with the external partners. Which Salesforce feature can help achieve this requirement?
Universal Containers develops a Visualforce page that requires the inclusion of external JavaScript and CSS files. They want to ensure efficient loading and caching of the page. Which feature should be utilized to achieve this goal?
Refer to the test method below:
Java
@isTest
static void testAccountUpdate() {
Account acct = new Account(Name = ' Test ' );
acct.Integration_Updated__c = false;
insert acct;
CalloutUtil.sendAccountUpdate(acct.Id);
Account acctAfter = [SELECT Id, Integration_Updated__c FROM Account WHERE Id = :acct.Id][0] ;
System.assert(true, acctAfter.Integration_Updated__c);
}
The test method calls a web service that updates an external system with Account information and sets the Account ' s Integration_Updated__c checkbox to True when it completes. The test fails to execute and exits with an error: " Methods defined as TestMethod do not support Web service callouts. " What is the optimal way to fix this?
An Apex trigger creates a Contract record every time an Opportunity is marked as Closed/Won. Historical records need to be loaded, but Contract records should not be created during this mass load. What is the most extendable way to update the Apex trigger to accomplish this?
A company wants to incorporate a third-party web service to set the Address fields when an Account is inserted, if they have not already been set. What is the optimal way to achieve this?
Which code snippet represents the optimal Apex trigger logic for assigning a Lead ' s Region based on its PostalCode, using a custom Region__c object?
Which interface needs to be implemented by an Aura component so that it may be displayed in a modal dialog by clicking a button on a Lightning record page?
A Visualforce page loads slowly due to the large amount of data it displays. Which strategy can a developer use to improve the performance?
A developer created and tested a Visualforce page in their developer sandbox, but now receives reports that users encounter " View State " errors when using it in production. What should the developer ensure to correct these errors?
To avoid duplicating code and improve maintainability, how should Universal Containers implement an API integration for code reuse?
A developer created an Apex class that updates an Account based on input from a Lightning web component. The update to the Account should only be made if it has not already been registered.
Java
account = [SELECT Id, Is_Registered__c FROM Account WHERE Id = :accountId];
if (!account.Is_Registered__c) {
account.Is_Registered__c = true;
// ...set other account fields...
update account;
}
What should the developer do to ensure that users do not overwrite each other’s updates to the same Account if they make updates at the same time?
An Apex trigger creates an Order__c record every time an Opportunity is won by a Sales Rep. Recently the trigger is creating two orders. What is the optimal technique for a developer to troubleshoot this?
Universal Charities (UC) uses Salesforce to collect electronic donations in the form of credit card deductions from individuals and corporations. When a customer service agent enters the credit card information, it must be sent to a 3rd-party payment processor for the donation to be processed. UC uses one payment processor for individuals and a different one for corporations. What should a developer use to store the payment processor settings for the different payment processors, so that their system administrator can modify the settings once they are deployed, if needed?
Universal Containers wants to develop a recruiting app for iOS and Android via the standard Salesforce mobile app. It has a custom user interface design and offline access is not required. What is the recommended approach to develop the app?
Refer to the following code snippet:
Java
public class LeadController {
public static List < Lead > getFetchLeadList(String searchTerm, Decimal aRevenue) {
String safeTerm = ' % ' +searchTerm.escapeSingleQuotes()+ ' % ' ;
return [
SELECT Name, Company, AnnualRevenue
FROM Lead
WHERE AnnualRevenue > = :aRevenue
AND Company LIKE :safeTerm
LIMIT 20
];
}
}
A developer created a JavaScript function as part of a Lightning web component (LWC) that surfaces information about Leads by wire calling getFetchLeadList when certain criteria are met. Which three changes should the developer implement in the Apex class above to ensure the LWC can display data efficiently while preserving security? 1
A company needs to automatically delete sensitive information after seven years. This could delete almost a million records every day. How can this be achieved?
