WorksheetsSalesforce PD2 - Review 1
Total questions: 56
Worksheet time: 30mins
A Visualforce page loads slowly due to the large amount of data it displays
Which strategy can a developer use to improve the performance?
Use the transient keyword for the List variables used in the custom controller.
Use JavaScript to move data processing to the browser instead of the controller.
Use an <apex:actionPoller> in the page to load all of the data asynchronously.
Use lazy loading to load the data on demand, instead of in the controller's contructor.
After a Platform Event is defined in a Salesforce org, events can be published via which two mechanisms ?
Choose 2 answers
Internal Apps can use Outbound Messages
Internal Apps can use Process Builder
External Apps require the standard Streaming API.
External Apps use an API to publish event messages.
A lead developer for a Salesforce organization needs to develop a page-centric application that allows the user to interact with multiple objects related to a Contact. The application needs to implement a third-party JavaScript framework such as Angular, and must be made available in both Classic and Lightning Experience.
Given these requirements, what is the recommended solution to develop the application ?
Aura Components
Lightning Web Components
Visualforce
Lightning Experience Builder
Universal Containers wants to use an external Web Service provided by a third-party vendor to validate the shipping and billing addresses are correct. The current vendor uses basic password authentication, but Universal Containers might switch to a different vendor who uses OAuth.
Which approach follows best practices and allows Universal Containers to switch vendors without updating the code to handle authentication?
Custom Setting (List)
Named Credential
Custom Metadata
Dynamic Endpoint
Which code statement includes an Apex method named updateAccounts in the class AccountController for use in a Lightning Web component?
import updateAccounts from '@salesforce/apex/AccountController';
import updateAccounts from 'AccountController';
import updateAccounts from 'AccountController.updateAccounts';
import updateAccounts from '@salesforce/apex/AccountController.updateAccounts';
Which statement is considered a best practice for writing bulk safe Apex Triggers?
Add records to collections and perform DML operations against these collections.
Perform all DML operations from within a Future Method.
Instead of DML statements, use the Database methods with allOrNone set to False.
Add LIMIT 50000 to every SOQL statement,
Universal Containers has an existing automation where a custom record called Account Plan is created upon an Account being marked as a Customer. Recently, a Workflow Rule was added so that whenever an Account is marked as a Customer, a 'Customer Since' date field is update with today's date.
Now, since the addition of the Workflow Rule, two Account Plan records are created whenever the Account is marked as a Customer.
What might cause this to happen ?
The Apex Trigger responsible for the record creation does not use a static variable to ensure it only fires once.
The Process Builder responsible for the record creation fires before and after the Workflow rule.
The Workflow Rule responsible for the record creation fires twice because the 'Customer Since' field Update is marked as 'Re-evaluate Workflow Rules After Field Change'.
The Apex Trigger responsible for the record creation is not bulk safe and calls Insert of a for loop
What is the best practice to initialize a Visualforce page in test class?
Use Test.currentPage.getParameters.put(MyTestPage);
Use Test.setCurrrentPage(Page.MyTestPage);
Use Test.setCurrentPage.MyTestPage;
Use controller.currentPage.setPage(MyTestPage);
A company has a custom object, Order__c, that has a custom picklist field, Status__c, with values of 'New', 'In Progress', or 'Fulfilled' and a lookup field, Contact__c, to Contact.
Which SOQL query will return a unique list of all Contact records that have no 'Fulfilled' Orders?
SELECT Contact__c FROM Order__c WHERE Id NOT IN (SELECT Id FFROM Order__c WHERE Status__c = 'Fulfilled')
SELECT Contact__c FROM Order__c WHERE Status__c <> 'Fulfilled'
SELECT Id FROM Contact WHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled' )
SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__C WHERE Status__c = 'Fulfilled' )
A developer is writing a Visualforce page that queries accounts in the system and presents a data table with the results. The users wants to be able to filter the results based on up to five fields. However, the users want to pick the five fields to use as filter fields when they run the page.
Which Apex code feature is required to facilitate this solution?
SOSL queries
Report API
Dynamic Schema binding
describeSObjects()
As part of an integration development effort, a developer is tasked to create an Apex method that solely relies on the use of foreign identifiers in order to relate new contact records to existing Accounts in Salesforce. The account object contains a field marked as an external ID, the API Name of this field is Legacy_Id__c.
What is the most efficient way to instantiate the parentAccount variable on the line 02 to ensure the newly created contact is properly related to the Account?
Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id__c = :externalIdentifier].Id;
Account parentAccount = new Account (Legacy_Id__c = externalIdentifier);
Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier];
Account parentAccount = new Account();
parentAccount.Id = externalIdentifier;
The use of the transient keyword in Visualforce Page Controllers helps with which common performance issue?
Improves Query Performance
Improves Page Transfers
Reduces Load Times
Reduces View State
A company wants to implement a new call center process for handling customer service calls. It requires service reps to ask for the caller's account number before proceeding with the rest of their call script.
Following best practices, what should a developer use to meet this requirement?
Approvals
Flow Builder
Apex Trigger
Process Builder
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 ?
Remote Site Settings
Connected Apps
Named Credentials
Session Id
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?
Schedule a batch Apex process to run every day that queries and deletes records older than seven years
Perform a SOSL statement to find records older than 7 years, and then delete the entire result set
Schedule an @future process to query records older than seven years, and then recursively invoke itself in 1,000 record batches to delete them
Use aggregate functions to query for records older than seven years, and then delete the AggregateResult objects
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.
Which feature should be used to implement these requirements?
Workflow
Process Builder
@future
Queueable
A company has a Lightning Page with many Lightning Components, some that cache reference data. It is reported that the page does not always show the most current reference data.
What can a developer use to analyze and diagnose the problem in the Lightning Page?
Salesforce Lightning Inspector Storage Tab
Salesforce Lightning Inspector Transactions Tab
Salesforce Lightning Inspector Actions Tab
Salesforce Lightning Inspector Event Log Tab
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 setting should the developer configure within the xml resource file
Choose 2 Answers
Set the IsVisible attribute to True
Set the IsExposed attribute to True
Specify the target to be lightning__AppPage
Specify the target to be lightning__RecordPage
Which statement is true regarding savepoints?
You can rollback to any savepoint variable created in any order.
Reference to savepoints can cross trigger invocations
Savepoints are not limited by DML statement governor limits.
Static variables are not reverted during rollback.
A company has code to update a request and Request Lines and make a callout to their external ERP system's REST endpoint with the update records.
The CalloutUtil.makeRestCalloutfails with a 'You have uncommitted work pending Please commit or rollback before calling out' error.
What should be done to address the problem?
Change the CalloutUtil.makeRestCallout to an @InvocableMethod method.
Move the Callout.makeRestCallout method call below the catch block.
Change the CalloutUtil.makeRestCallout toan @future method.
Remove the Database.setSavepoint and Database.rollback.
A custom object called Credit_Memo__c exists in a Salesforce environment. As part of a new feature development that retrieves and manipulates this type of record, the developer needs to ensure race conditions are prevented when a set of records are modified within an Apex transaction.
In the preceding Apex code, how can the developer alter the query statement to use SOQL features to prevent race conditions within a transaction?
[SELECT Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR VIEW]
[SELECT Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR REFERENCE]
[SELECT Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR UPDATE]
[SELECT Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId USING SCOPE LIMIT 50]
A company wants to build a custom Aura components that displays a specified Account Field Set and that can only be added to the Account record page.
Which design resource configuration should be used?
A Visualforce page contains an industry select list and displays a table of Accounts that have a matching value in their Industry field.
<apex:selectList value="{!selectedIndustry}">
<apex:selectOptions values="{!industries}"/>
</apex:selectList>
When a user changes the value on the industry select list, the table of Accounts should be automatically updated to shown the Accounts associated with the selected industry.
What is the optimal way to implement this?
Add an <apex:actionFunction> within <apex:selectList>.
Add an <apex:actionSupport> within <apex:selectList>.
Add an <apex:actionFunction> within <apex:selectOptions>.
Add an <apex:actionSupport> within <apex:selectOptions>.
Which scenario requires a developer to use an Apex callout instead of Outbound Messaging?
The target system uses a REST API.
The callout needs to be Invoked from a Workflow Rule
The target system uses a SOAP API.
The callout needs to be asynchronous.
Which two relationship queries use the proper syntax?
SELECT Name, (SELECT LastName FROM Contacts__r) FROM Account
SELECT Name, (SELECT LastName FROM Contacts) FROM Account
SELECT Id, Name, Account.Name FROM Contact WHERE Account.Industry = 'Media'
SELECT Id , Name, Account__r.Name FROM Contact WHERE Account__r.Industry = 'Media'
As part of a custom development, a developer creates a Lightning Component to show how a particular opportunity progresses over time. The component must display the date stamp when any of the following fields change:
Amount, Probability, Stage, or Close Date
What is the most efficient way to query such information?
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. Also, Workflows that once sent emails and created task no longer do so.
Which two statements are true regarding these issues and resolution?
Choose 2 answers.
Page Layouts should never be deployed via Change Sets, as this causes Workflows and Field-level Security to be reset and fields to disappear.
The administrators are deploying their own Change Sets over each other, thus replacing entire Page Layouts and Workflows in Production.
A sandbox should be created to use as a unified testing environment instead of deploying Change Sets directly to production.
The administrators are deploying their Change Sets, thus deleting each other's fields from the objects in production.
An Apex Trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. This trigger is working great, except (due to a recent acquisition) historical Opportunity records need to be loaded into the Salesforce instance.
When a test batch of records is loaded, the Apex Trigger creates Contract records. A developer is tasked with preventing Contract records from being created when mass loading the Opportunities, but the daily users still need to have the Contract records created.
What is the most extendable way to update the Apex Trigger to accomplish this?
Use a List Custom Setting to disable the trigger for the user who loads the data.
Add the Profile ID of the user who loads the data to the trigger so the trigger will not fire for this user.
Use the Hierarchy Custom Setting to skip executing the logic inside the trigger for the user who loads the data.
Add a Validation Rule to Contract to prevent Contract creation by the user who loads the data.
Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account?
Assuming the CreateOneAccount class creates one account and implements the Queueable interface, which syntax tests the Apex code?
A company uses custom-built enterprise resource planning (ERP) system to handle order management. The company want Sales reps to know the status of orders so that if a customer calls to ask about their shipment, the Sales Rep can advise the customer about the order's status and tracking number if it is already shipped.
Which two methods can make this ERP order data visible in Salesforce?
Choose 2 answers
Have the ERP system push the data into Salesforce using the SOAP API
Use Salesforce Connect to view real-time Order data in the ERP system.
Write a cron job in Salesforce to poll the ERP system for order updates.
Ensure real-time order data is in Salesforce using the Streaming API
Refer to the code segment above.
When following best practices for writing Apex triggers, which two lines are wrong or cause for concern?
Choose 2 answers
Line 6
Line 11
Line 16
Line 20
A developer is integrating with a legacy on-premise SQL database.
What should the developer use to ensure the data being integrated is matched to the right records in Salesforce?
External Id field
Lookup field
Formula field
External Object
An Aura component has a section that displays some information about an Account and it works well on the desktop, but users have to scroll horizontally to see the description field output on their mobile devices and tablets.
<lightning:layout multipleRows="false">
<lightning:layoutItem size="6"> {!v.rec.Name} </lightning:layoutItem>
<lightning:layoutItem size="6"> {!v.rec.Description__c} </lightning:layoutItem>
</lightning:layout>
Which option has the changes to make the component responsive for mobile and tablet devices?
Universal Containers stores user preferences in a Hierarchy Custom Setting, User_Prefs__c, with a Checkbox field, Show_Help__c. Company-level defaults are stored at the organizational level, but may be overridden at the user level. If a user has not overridden preferences, then the defaults should be used.
How should the Show_Help__c preference be retrieved for the current user?
Boolean show = User_Prefs__c.getInstance().Show_Help__c;
Boolean show = User_Prefs__c.getValues().Show_Help__c;
Boolean show = User_Prefs__c.Show_Help__c;
Boolean show = User_Prefs__c.getValues(UserInfo.getUserId()).Show_Help__c;
Users complain that a page is very slow to respond. Upon investigation, the query below is found to perform slowly.
SELECT Id, Name FROM Contact WHERE CustomField__c = null;
Which two actions can a developer take to improve performance?
Choose 2 answers
Add a LIMIT clause to the query to reduce the number of records returned.
Contact Salesforce customer support to create a custom index to include null values.
Make the CustomField__c field an External ID
Make the field CustomField__c required because Salesforce field indexes do not include nulls.
A developer is tasked with ensuring that email addresses entered into the system for Contacts and for a Custom Object called Survey_Response__c do not belong to a list of blocked domains. The list of blocked domains will be stored in a custom object for ease of maintenance by users. Note that the Survey_Response__c object is populated via a custom Visualforce page.
What is the optimal way to implement this?
Implement the logic in an Apex trigger on Contact and also implement the logic within the Custom Visualforce page controller.
Implement the logic in a helper class that is called by an Apex trigger on Contact and from the Custom Visualforce page controller
Implement the logic in a Validation Rule on the Contact and a Validation Rule on the Survey_Response__c object.
Implement the logic in the Custom Visualforce page controller and call that method from an Apex trigger on Contact.
How should a developer verify that a specific Account record is being tested in a test class for a Visualforce controller?
Instantiate the page reference in the test class, Insert the Account in the test class, then use System.setParentRecordId().get() to set the Account ID.
Instantiate the page reference in the test class, insert the Account in the test class, then use seeAllData=true to view the Account.
Insert the Account into Salesforce, instantiate the page reference in the test class, then use System.setParentRecordId().get() to set the Account ID.
Insert the Account in the test class, instantiate the page reference in the test class, then use System.currentPageReference().getParameters().put() to set the Account ID
A developer has a Batch Apex process, Batch_Account_Sales, that updates the sales amount for 10,000 Accounts on a nightly basis. The Batch Apex works as designed in the sandbox. However, the developer cannot get code coverage on the Batch Apex class.
The test class below:
What is causing the code coverage problem?
The batch process will not recognize new accounts created in the same session
The account creation already sets the sates amount to 0.
The executeBatch must fail within test. startTest ( ) and test. stopTest().
The batch needs more than one account record created.
An Apex class does not achieve expected code coverage. The testSetup method explicitly calls a method in the Apex class.
How can the developer generate the code coverage?
Call the Apex class method from the a testMethod instead of the testSetup method.
Use system.assert() in testSetup to verify the values are being returned.
Verify the user has permissions passing a user into System.runAs().
Add @testVisible to the method in the class the developer is testing
A Visualforce page needs to make a callout to get billing information and tax information from two different REST endpoints. The Information needs to be displayed to the user at the same time and the return value of the billing information contains the input for the tax information callout. Each endpoint might take up to two minutes to process.
How should a developer implement the callouts?
A Continuation for both the billing callout and the tax callout.
An HTTP REST callout for both the billing callout and tax callout.
An HTTP REST callout for billing callout and a Continuation for the tax callout.
A Continuation for the billing callout and an HTTP REST callout for tax callout
A developer is writing code that requires making callouts to an external web services.
Which scenario necessitates that the callout be made in an @future method?
The callouts will be made in an Apex Test class
The callout could take longer than 60 seconds to complete
The callout will be made in an Apex Trigger
Over 10 callouts will be made in a single transaction
Users report that a button on a custom Lightning web component is not working. However, there are no other details provided.
What should the developer use to ensure error messages are properly displayed?
Use the Database method with allOrNone set to false.
Add JavaScript and HTML to display an error message.
Add the <apex:message/> tag to the component
Add a try-catch block surrounding the DML statement.
A company represents their customers as Accounts in Salesforce. All customers have a unique Customer_Number__c that is unique across all of the company's systems. They also have a custom Invoice__c object, with a Lookup to Account, to represent invoices that are sent out from their external system. This company wants to integrate invoice data back into Salesforce so Sales Reps can see when a customer is paying their bills on time.
What is the optimal way to implement this?
Use Salesforce Connect and external data objects to seamlessly import the invoice data into Salesforce without custom code.
Ensure Customer_Number__c is an External ID and that a custom field Invoice_Number__c is an External ID and Upsert invoice data nightly.
Create a cross-reference table in the custom invoicing system with the Salesforce Account ID of each Customer and insert invoice data nightly.
Query the Account Object upon each call to insert invoice data to fetch the Salesforce ID corresponding to the Customer Number on the invoice.
A developer wishes to improve runtime performance of Apex calls by caching results on the client.
What is the most efficient way to implement this?
Decorate the server-side method with @AuraEnabled(cacheable=true)
Decorate the server-side method with @AuraEnabled(storable=true)
Set a cookie in the browser for use upon return to the page.
Call the setStorable() method on the action in the JavaScript client-side code
The Contact object in an org is configured with the workflow rules that trigger field updates. The fields are not updating, even though the end user expects them to. The developer creates a debug log to troubleshoot the problem.
What should the developer specify in the debug log to see the values of the workflow rule conditions and debug the problem?
ERROR level for the Workflow log category
INFO level for the Workflow log category
INFO level for the Database log category
ERROR level for the Database log category
A developer is building a Lightning web component to get data from an Apex method called getData that takes a parameter, name. The data should be retrieved when the user clicks the Load Data button.
What must be added to get the data?
Add @wire(getData, (name: $name’)} to the account field and this, account = getData ( ) ; to t loadData ( ) function.
Add this, account = getData (this,name); to the loadData ( ) function
Add getData ({ name; this,name}) , then (result=> { this.account = result}) to the LeadData ( ) function
Add @wire(getData, {name: $name’}) to the account field and delete loadData ( ) because it is not needed
Universal Containers needs to integrate with a Heroku service that resizes product images submitted by users.
What are two alternatives to implement the integration and protect against malicious calls to the Heroku app's extension?
Choose 2 answers
Create a Workflow Rule with an Outbound Message allowing the Heroku app to automatically store the resized images in Salesforce
Create a Workflow Rule with an Outbound Message and select Send Session ID so that the Heroku app can use it to send the resized images back to Salesforce.
Create a trigger that uses an ©future Apex HTTP callout passing JSON serialized data; therefore the Heroku app can automatically reply back to the callout with the resized images in Salesforce.
Create a trigger that uses an ©future Apex HTTP callout passing JSON serialized data and some form of pre-shared secret key, so that the Heroku app can authenticate requests and store the resized images in Salesforce.
A developer creates an application event that has triggered an infinite loop.
What may have cause this problem?
The event is fired from a custom renderer
An event is fired 'ontouchend' and is unhandled.
The event has multiple handlers registered in the project
The event handler calls a trigger
How can a developer efficiently incorporate multiple JavaScript libraries in a Lightning component?
Use JavaScript remoting the script tags
Use CDNs with scripts attributes
Join multiple assets from a static resource
Implement the libraries in a separate helper files
A developer wrote a trigger on Opportunity that will update a custom Last Sold Date field on the Opportunity's Account whenever an Opportunity is closed. In the test class for the trigger, the assertion to validate the Last Sold Date field fails.
What might be causing the failed assertion?
The test class not implemented seeAllData=true in the test method.
The test class has not re-quired the Account record after updating the Opportunity
The test class is not using System.runAs() to run tests as a Salesforce administrator
The test class has not defined an Account owner when inserting the test data
What is a benefit of JavaScript remoting over Visualforce Remote Objects?
Does not require any Apex code
Allows for specified re-render targets
Does not require any JavaScript code
Support complex server-side application logic
A developer is asked to build a solution that will automatically send an email to the Customer when an Opportunity stage changes. The solution must scale to allow for 10,000 emails per day. The criteria to send the email should be evaluated after all Workflow Rules have fired.
What is the optimal way to accomplish this?
Use a MassEmailMessage() with an Apex Trigger.
Use a Workflow Email Alert.
Use an Email Alert with Process Builder.
Use a SingleEmailMessage() with an Apex Trigger.
A developer created and tested a Visualforce page in their developer sandbox, but now receives reports that users are encountering ViewState errors when using it in Production.
What should the developer ensure to correct these errors?
Ensure queries do not exceed governor limits.
Ensure properties are marked as Transient.
Ensure properties are marked as private.
Ensure profiles have access to the Visualforce page.
A developer created an Apex class that makes outbound RESTful callout. The following was created to send a fake response in Apex test methods.
Which method can be called to return this fake response in the test methods?
testSetup
Test.createSub
Test.setMock
Test.setTestData
Which technique can run custom logic when a Lightning web component is loaded?
Use an aura:handler "init" event to call a function
Use the renderedCallback() method.
Call $A.enqueueAction passing in the method to call.
Use the connectedCallback() method.
