Salesforce Platform Developer II Exam Practice Test

Page: 1 / 14
Total 202 questions
Question 1

A developer creates a Lightning web component to allow a Contact to be quickly entered. However, error messages are not displayed.

Which component should the developer add to the form to display error messages?



Answer : B

The correct answer is B, lightning-messages. This Lightning Web Components (LWC) service component provides a way to display error messages that are generated during the processing of lightning-input-field components within a lightning-record-edit-form.


Display Error Messages

Question 2

A developer is building a Lightning web component that retrieves data from Salesforce and assigns it to the record property.

What must be done in the component to get the data from Salesforce?

A)

B)

C)



Answer : A

Option A is the correct answer. The @wire decorator is used in conjunction with getRecord from lightning/uiRecordApi to retrieve a record from Salesforce. The syntax @wire(getRecord, { recordId: '$recordId', fields: '$fields' }) sets up a reactive property, which means it will automatically rerun whenever the recordId or fields property changes.


Get Record Data

Question 3

Exhibit.

Given the code above, which two changes need to be made in the Apex Controller for the code to work? Choose 2 answers



Answer : B, D

Based on the code provided, here are the necessary changes:

Change B is required because the argument in the Apex controller's serverEcho method must match the data type expected by the JavaScript calling the method. The Apex method expects an Object named firstName, which is then cast to a String inside the method. The JavaScript is passing an object with a property firstName, so no change is needed in the JavaScript.

Change D is correct because line 06 is redundant and unnecessary. We can directly use firstName in the return statement as it is already a String type. The get() method is typically used when you have a Map and you need to retrieve a value by its key. Since firstName is already being passed as a String, there's no need to cast it or retrieve it using get().


Apex Developer Guide

Question 4

An org has an existing process, built using Process Builder, on Opportunity that sets a custom field, CommissionBaseAmount__c, when

an Opportunity is edited and the Opportunity's Amount changes.

A developer recently deployed an Opportunity before update trigger that uses the CommissionBaseAmount__c and complex logic to calculate a

value for a custom field, CommissionAmount__c, when an Opportunity stage changes to Closed/Won.

Users report that when they change the Opportunity to Closed/Won and also change the Amount during the same save, the CommissionAmount__c is incorrect.

Which action should the developer take to correct this problem?



Answer : A

The issue described is likely due to the order of execution in Salesforce, where processes in Process Builder run after all before triggers. If the Opportunity's Amount is changed and the CommissionBaseAmount__c is set by Process Builder, the trigger that calculates CommissionAmount__c may not see the updated value if it operates before the process.

Replacing the process with a before-save record-triggered flow (formerly known as Fast Field Update) would ensure that CommissionBaseAmount__c is updated before the trigger runs. In a before-save flow, field updates occur before any Apex before update triggers fire, which means the trigger would have the updated value of CommissionBaseAmount__c to use in its calculation.


Order of Execution in Salesforce

Before-Save Record-Triggered Flows

Question 5

Which code snippet processes records in the most memory efficient manner, avoiding governor limits such as "Apex heap size too large"?

A)

B)

C)

D)



Answer : D

Option D, which uses the Database.query() method in combination with a for loop, is the most memory-efficient way to process records. This is known as the Query Locator pattern, which allows you to work with a large number of records by querying them in batches. This approach helps to avoid hitting the governor limit for 'Apex heap size too large' as it processes one record at a time from the database without storing the entire result set in memory.


Working with Very Large SOQL Queries

Apex Governor Limits

Question 6

A developer is tasked with creating a Lightning web component that allows users to create a Case for a selected product, directly from a custom Lightning page. The input fields in the component are displayed in a non-linear fashion on top of an image of the product to help the user better understand the meaning of the fields.

Which two components should a developer use to implement the creation of the Case from the Lightning web component?

Choose 2 answers



Answer : C, D

To implement a Lightning web component that allows users to create a Case, you would need components that allow for input fields and the creation of records.

Option C (Lightning-input) is correct because it allows developers to create custom form input elements that can be positioned in a non-linear fashion as required.

Option D (lightning-record-form) is correct because it provides a simple way to create forms for viewing and editing Salesforce records and would be suitable for creating a new Case record.

Option A (Lightning-record-edit-form) is not a valid component; it seems to be a misprint of lightning-record-edit-form, which is indeed a component used for creating and editing records but was not listed as an option.

Option B (lightning-input-field) is used within the lightning-record-edit-form or lightning-record-view-form components to create editable or displayable fields respectively, but is not as versatile as lightning-input for custom layout purposes.


Lightning Web Components Documentation: Lightning-input

Question 7

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?



Answer : A

In a scenario where an integration requires making a callout to an external web application, Apex is often used to perform callouts. The callout must be asynchronous when being made from a trigger because a callout cannot be made from a synchronous operation like a trigger due to the possibility of long-running transactions.

Option A (An Apex trigger that calls an @future method that allows callouts) is correct because it enables the trigger to perform an asynchronous callout to the external web application, which is necessary for sending JSON payloads and receiving the resized images.

Options B, C, and D do not fit the requirement as well as option A because platform events and flows are typically not used for making direct callouts to external systems in the context described.


Apex Developer Guide: Apex Web Services and Callouts

Page:    1 / 14   
Total 202 questions