Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

PD 2

Q. When developing a Lightning web component, which setting displays lightning-layout-items in one
column on small devices, such as mobile phones, and in two columns on tablet-size and desktop-size
screens?

Answer: Set size="12" medium-device-size="6"

Q. 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?

Answer: The test class has not re-queried the Account record after updating the Opportunity.

Q. What is a benefit of JavaScript remoting over Visualforce Remote Objects?

Answer: Supports complex server-side application logic

Q. A company manages information about their product offerings in custom objects named Catalog
and Catalog Item. Catalog Item has a master-detail field to Catalog, and each Catalog may have as
many as 100,000 Catalog Items. Both custom objects have a CurrencyIsoCode Text field that
contains the currency code they should use. If a Catalog's CurrencyIsoCode changes, all its Catalog
Items' CurrencyIsoCodes should be changed as well. What should a developer use to update the
CurrencyIsoCodes on the Catalog Items when the Catalog's CurrencyIsoCode changes?

Answer: A Database. Schedulable and Database. Batchable class that queries the Catalog Item
object and updates the Catalog Items if the Catalog CurrencyIsoCode is different

Q. Consider the following code snippet, depicting an Aura component:

<aura:component>

<lightning:input type=”Text” name=”searchString” aura:id=”search1” label=”Search


String”/>

<br/>

<lightning:button label=”Search” onclick=”{!c.performSearch}”/>

</aura:component>

Which two interfaces can the developer implement to make the component available as a quick
action? Choose 2 answers.

Answer: force:lightningQuickAction

force:lightning QuickAction without Header


Q. Refer to the code snippet below:

01 public void createChildRecord (String externalIdentifier) {

02 Account parentAccount;

03

04 Contact newContact = new contact();

05. newContact. Account = parentAccount;

06

07 insert (newContact);

08 }

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 line 02 to ensure the newly
created contact is properly related to the Account ?

Answer: Account parentAccount = [SELECT ID FROM Account WHERE Legacy_Id_c =


externalIdentifier];

Q. Which three Visualforce components can be used to initiate Ajax behavior to perform partial page
updates?

Choose 3 answers

Answer:

<apex: commandButton>

<apex:commandLink>

<apex:actionSupport>

Q. Which statement is considered a best practice for writing bulk safe Apex triggers?

Answer: Add records to collections and perform DML operations against these collections.

Q. global with sharing class MyRemoter {

public String account Name get; set; }

public static Account account get; set; }

public MyRemoter() { }
@Remotection

global static Account getAccount (String account Name)

account = (SELECT ID, Name, Number Employees EROM Account WHERE Name = : account
Name);

return account.

Consider the Apex class above that defines a Remote Action used on a Visualforce search page.

Which code snippet will assert that the remote action returned the correct Account?

Answer: Account a = MyRemoter.getAccount("TestAccount');

System.assertEquals( 'TestAccount', a. Name);

Q. When calling a RESTful web service, the developer must implement two-way SSL authentication
to enhance security. The Salesforce admin has generated a self-sign certificate within Salesforce with
a unique name of "ERPSecCertificate".

Consider the following code snippet:

HttpRequest req = new HttpRequest();

... // rest of request

Which method must the developer implement in order to sign the HTTP request with the certificate?

Answer: reg.setClientCertificateName('ERPSecCertificate');

Q. A developer created a JavaScript library that simplifies the development of repetitive tasks and
features and uploaded the library as a static resource called jsutils in Salesforce. Another developer is
coding a new Lightning web component (LWC) and wants to leverage the library.

Which statement properly loads the static resource within the LWC?

Answer: import jsutilities from ‘@salesforce/resourceUrl/jsUtils':

Q. A company has reference data stored in multiple custom metadata records that represent default
information and delete behaviour for certain geographic regions.

When a contact is inserted, the default information should be set on the contact from the custom
metadata records based on the contact's address information. Additionally, if a user attempts to delete
a contact that belongs to a flagged region, the user must get an error message.

What is the optimal way to automate this?

Answer: Apex trigger


Q. A developer is tasked with creating an application-centric feature on which end-users can access
and update information. This feature must be available in Lightning Experience while working
seamlessly in multiple device form factors, such as desktops, phones, and tablets. Additionally, the
feature must support Addressable URL Tabs and interact with the Salesforce Console APIs. What are
two approaches a developer can take to build the application and support the business requirements?

Choose 2 answers

Answer: Create the application using Lightning Web Components wrapped in Aura Components.

Create the application using Aura Components.

Q. 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_Numero__c, that is then used in a query to find matching Accounts.

ErpNumber = erpNumber + ‘%’;

List <Account> accounts = (SELECT Id, Name FROM Account WHERE ERP_Number_c LIKE
:erplumber]

A developer receives the exception 'SOQL query not selective enough'.

Which step should be taken to resolve the issue?

Answer: Mark the ERP_Number_c field as an external ID.

Q. A developer has a test class that creates test data before making a mock callout but now receives
a 'You have uncommitted work pending.

Please commit or rollback before calling out' error.

Which step should be taken to resolve the error?

Answer: Ensure the records are inserted before the Test.startest() statement and the mock callout
occurs after the Test.startTest().

Q. A developer creates an application event that has triggered an infinite loop.

What may have caused this problem?

Answer: The event is fired from a custom renderer.

Q. There is an Apex controller and a Visualforce page in an org that displays records with a custom
filter consisting of a combination of picklist values selected by the user.

The page takes too long to display results for some of the input combinations, while for other input
choices it throws the exception, "Maximum view state size limit exceeded".

What step should the developer take to resolve this issue?

Answer: Use a StandardSetController or SOQL LIMIT in the Apex controller to limit the number of
records displayed at a time.
Q. A company uses Opportunities to track sales to their customers and their org has millions of
Opportunities. They want to begin to track revenue over time through a related Revenue object.

As part of their initial implementation, they want to perform a one-time seeding of their data by
automatically creating and populating Revenue records for Opportunities, based on complex logic.

They estimate that roughly 100,000 Opportunities will have Revenue records created and populated.
What is the optimal way to automate this?

Answer: Use Database.executeBatch() to invoke a Database. Batchable class.

Q. A developer notices the execution of all the test methods in a class takes a long time to run, due to
the initial setup of all the test data that is needed to perform the tests.

What should the developer do to speed up test execution?

Answer: Define a method that creates test data and annotate with test setup.

Q. Ursa Major Solar has a custom object, Service Job_e, with an optional Lookup field to Account
called Partner_Service_Provider_c. The Totaljobs_c field on Account tracks the total number of
ServiceJob_c records to which a partner service provider Account is related.

What should be done to ensure that the totaljobs_c field is kept up to date?

Answer: Create an Apex trigger on ServiceJob_c

Q. An Apex trigger and Apex class increment a counter, Edit_Count_c, any time the Case is
changed.

public class CaseTriggerHandler {

public static void handle (List <case> cases) {

for (Case: cases) {

c. Edit_Count_c = c.Edit_count_c + 1;

trigger on Case (before update) {

CameTriggerHandler, handle (Trigger.new);

A new process on the Case object was just created in production for when a Case is created or
updated. Since the process was added, there are reports that Edit_Count_c is being incremented
more than once for Case edits.

Which Apex code fixes this problem?


Answer: public class Case TriggerHandler {

public static Boolean first Run = true;

public static void handle (List <case> cases) {

for (Case c: cases) {

c. Edit_count_c = c. Edit_Count__ + 1;

trigger on Case (before update) {

if (CageTriggerHandler.firstRun) {

CaseTrigger Handler.handle(Trigger.new);

CaseTriggerHandler. FirstRun = false;

Q. A company represents their customers as Accounts that have an External ID field called
Customer_Number__c. They have a custom Order (Order_c) object, with a Lookup to Account, to
represent Orders that are placed in their external order management system (OMS). When an order
is fulfilled in the OMS, a REST call to Salesforce should be made that creates an Order record in
Salesforce and relates it to the proper Account.

What is the optimal way to implement this?

Answer: Perform a REST PATCH to upsert the Order_c and specify the Account's
Customer_Number_c in it.

Q. A developer is debugging an Apex-based order creation process that has a requirement to have
three savepoints, SP1, SP2, and SP3 (created in order), before the final execution of the process.

During the final execution process, the developer has a routine to roll back to SP1 for a given
condition. Once the condition is fixed, the code then calls a roll back to SP3 to continue with final
execution. However, when the roll back to SP3 is called, a runtime error occurs.

Why does the developer receive a runtime error?

Answer: SP3 became invalid when SP1 was rolled back.

Q. Refer to the code snippet below:

public static void updateCreditMemo (String customer Id, Decimal new Amount) {

List<Credit_Memo__c> toUpdate = new List <Credit_Memo__c>();

for (Credit_Memo__c creditMemo: [Select Id, Name, Amount_c FROM Credit Memec WHERE
Customer Id LIMIT 50]) {
credstMemo. Amount_c= new Amount;

toUpdate.add(creditMemo);

Database.update (toUpdate, false);

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 w 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?

Answer: [Select Id, Name, Amount_c FROM Credit_Memo__c WHERE customer_id_c =: customerId
LIMIT 50 FOR UPDATE]

Q. Which two scenarios require an Apex method to be called imperatively from a Lightning web
component?

Choose 2 answers

Answer: Calling a method that is not annotated with cacheable=true

Calling a method with the click of a button

Q. A developer is writing a Visualforce page that queries accounts in the system and presents a data
table with the results. The users want 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?

Answer: Dynamic variable binding

Q. A company wants to build a custom Aura component 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?

Answer: <design:component label=”Account FS Component”>

<design:attribute name=”fieldSetName” label=”Field Set Name”/>

<sfdc:objects>

<sfdc:object>Account</sfdc:object>

</sfdc:objects>

</design:component>
Q. A company recently deployed a Visualforce page with a custom controller that has a data grid of
information about Opportunities in the org. Users report that they receive a "Maximum view state size
limit" error message under certain conditions.

According to Visualforce best practice, which three actions should the developer take to reduce the
view state?

Choose 3 answers

Answer: Refine any SOQL queries to return only data relevant to the page.

Use filters and pagination to reduce the amount of data.

Use the transient keyword in the Apex controller for variables that do not maintain state.

Q. An Apex class does not achieve expected code coverage. The test Setup method explicitly calls a
method in the Apex class. How can the developer generate the code coverage?

Answer: Call the Apex class method from a testMethod instead of the testSetup method.

Q. A business process requires sending new Account records to an external system. The Account
Name, Id, CreatedDate, and CreatedById must be passed to the external system in near real-time
when an Account is inserted without error. How should a developer achieve this?

Answer: Use a Process Builder that calls an @InvocableMethod method.

Q. A developer created a Lightning web component that uses a lightning-record-edit-form to collect


information about Leads. Users complain that they only see one error message at a time about their
input when trying to save a Lead record. Which best practice should the developer use to perform the
validations on more than one field, thus allowing more than one error message to be displayed
simultaneously?

Answer: Client-side validation

Q. A developer has a Visualforce page that automatically assigns ownership of an Account to a queue
upon save. The page appears to correctly assign ownership, but an assertion validating the correct
ownership fails. What can cause this problem?

Answer: The test class does not retrieve the updated value from the database.

Q. 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?

Answer: Use Queueable apex to chain the jobs to run sequentially.

Q. An org has a requirement that addresses on Contacts and Accounts should be normalized to a
company standard by Apex code any time that they are saved. What is the optimal way to implement
this?
Answer: Apex triggers on Contact and Account that call a helper class to normalize the address.

Q. The Salesforce admin at Cloud Kicks created a custom object called Region_c to store all postal
zip codes in the United States and the Cloud Kicks sales region the zip code belongs to.

Object Name:

Region_c

Fields:

Zip_Code__c (Text)

Region_Name_c (Text)

Cloud Kicks wants a trigger on the Lead to populate the Region based on the Lead's zip code.

Which code segment is the most efficient way to fulfill this request?

Answer:

Set <String> zips = new Set<String>;

for (Lead 1 : Trigger.new) {

if(1. Postal Code != Null) {

zips.add(1. Postal Code);

List <Region__c> regions = [SELECT Zip_code_c, Region_Name_c FROM Region_c WHERE


Zip_code__C IN :zips];

Map<string,String> zipMap = new Map< string,String >();

for (Region_c r regions) {

zipMap.put (r.Zip_code_c, r. Region_Name__c);

for (Lead 1 : Trigger.new) {

if (1. Postal Code != null) {

Region_c = zipMap.get (1. Postal Code);

}
Q. Refer to the code snippet below:

Import fetchOpps from ‘@salesforce/apex/OpportunitySearch. fetchOpportunities'

@wire(fetchopps)

Opportunities;

When a Lightning web component is rendered, a list of opportunities that match certain criteria should
be retrieved from the database and displayed to the end-user.

Which three considerations must the developer implement to make the fetchopportunities method
available within the Lightning web component?

Choose 3 answers

Answer:

The method must specify the (cacheable=true) attribute

The method cannot mutate the result set retrieved from the database.

The method must be annotated with the invocableMethod annotation

Q. A developer has a requirement to query three fields (Id, Name, Type) from an Account; and first
and last names for all Contacts associated with the Account

Which option is the preferred, optimized method to achieve this for the Account named 'Ozone
Electronics'?

Answer: Account a = [SELECT ID, Name, Type, (SELECT FirstName, LastName FROM Contacts)
FROM Account WHERE name='Ozone Electronics' LIMIT 1];

Q. Consider the following queries. For these queries, assume that there are more than 200,000
Account records. These records include softdeleted records; that is, deleted records that are still in
the Recycle Bin. Note that there are two fields that are marked as External Id on the Account. These
fields are Customer_Number_c and ERP_Key_c.

Which two queries are optimized for large data volumes?

Choose 2 answers

Answer: SELECT Id FROM Account WHERE Name != '' AND Customer_Number_c = 'ValueA’

SELECT ID FROM Account WHERE IS IN :aListVariable

Q. A company has many different unit test methods that create Account records as part of their data
setup. A new required field was added to the Account and now all of the unit tests fail.
What is the optimal way for a developer to fix the issue?

Answer: Create a TestDataFactory class that serves as the single place to create Accounts for unit
tests and set the required field there.

Q. A developer needs to store variables to control the style and behavior of a Lightning Web
Component.

Which feature should be used to ensure that the variables are testable in both Production and all
Sandboxes?

Answer:

Custom Metadata

Q. A company uses their own custom-built enterprise resource planning (ERP) system to handle
order management. The company wants 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 has shipped.

Which two methods can make this ERP order data visible in Salesforce?

Choose 2 answers

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

Question: A developer is asked to develop a new AppExchange application. A feature of the program
creates Survey records when a Case reaches a certain stage and is of a certain Record Type. This
feature needs to be configurable, as different Salesforce instances require Surveys at different times.
Additionally, the out-of-the-box AppExchange app needs to come with a set of best practice settings
that apply to most customers.

What should the developer use to store and package the custom configuration settings for the app?

Answer: Custom Metadata

Question:
Question

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__ FROM Region WHERE Name = anaccount.Region


Name__c];

anAccount. OwnerId = theRegion.Region_Manager_c;

accountList.add( anaccount);

update accountList;

Consider the above trigger intended to assign the Account to the manager of the Account's region,

Which two changes should a developer make in this trigger to adhere to best practices?

Choose 2 answers

Answer:

Remove the last line updating accountaiat as it is not needed.

Move the Region_c query to outside the loop.

Question:
Refer to the following code snippet:

public class LeadController {

public static List <Lead> getFetchLeadList(String searcherm, Decimal Revenue) {

String safeTerm = '%'+searchTerm.escapeSingleQuote() +'%'

return [

SELECT Name, Company, Annual Revenue FROM Lead WHERE Annual Revenue >= :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 getFetchteadList 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?

Choose 3 answers

Annotate the Apex method with AuraEnabled (Cacheable true).

Implement the with sharing keyword in the class declaration.

Use the WITH SECURITY_ENFORCED clause within the SOQL query.

Question:

Refer to the code below:

Apex Class:

public class OppController {

public List<Opportunity > getTopOpps() {


return [SELECT Name FROM Opportunity ORDER BY Amount DESC LIMIT 10];

Component markup:

<aura:component>

<aura:handler name="init" value="{this)" action="{!c.doInit)"/>

</aura:component>

Component controller:

{{

doinit : function(cmp, event, helper) {

var action = cmp.get ("c.getTopOpps");

action.setCallback(this, function (response){

var state = response.getState();

if (state == "SUCCESS") {

console.log("From server:" + response.getReturnValue());

});

$A.enqueuection (action);

A developer is building this Aura component to display information about top Opportunities in the org.

Which three code changes must be made for the component to work?

Choose 3 answers

Add the static keyword to the Apex method.

Set the controller in the component markup.

Add the AuraEnabled annotation to the Apex method.

Question: Just prior to a new deployment the Salesforce administrator, who configured a new order
fulfilment process feature in a developer sandbox,suddenly left the company.

As part of the UAT cycle, the users had fully tested all of the changes in the sandbox and signed off
on them; making the Order fulfilment feature ready for its go-live in the production environment.

Unfortunately, although a Change Set was started, it was not completed by the former administrator.
A developer is brought in to finish the deployment.

What should the developer do to identify the configuration changes that need to be moved into
production?

Answer: Leverage the Setup Audit Trail to review the changes made by the departed Administrator
and identify which changes should be added to the Change Set.
Question

A company uses an external system to manage its custom account territory assignments. Every
quarter, millions of Accounts may be updated

In Salesforce with new Owners when the territory assignments are completed in the external system.

What is the optimal way to update the Accounts from the external system?

Answer: Apex Rest Web Service

Question: 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 method for a developer to troubleshoot this?

Answer: Add system.debug() statements to the code and use the Developer Console logs to trace the
code

Question: After a Platform Event is defined in a Salesforce org, events can be published via which two
mechanisms?

Choose 2 answers

Answer: External Apps use an API to publish event messages.

Internal Apps can use Process Builder

Question:

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

import { Lightning Element, api, wire} from 'lwc';

import { getRecord } From 'lightning/usRecordApi';

export default class Record extends LightningElement {

@api fields;

@api recordId;

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

Answer:

Add the following code above record;

@wire (getRecord, {recordid: '$recordid', fields: 'fields' })

Question: An org has a requirement that the Shipping Address on the Account must be validated by a
third-party web service before the Account is

allowed to be inserted. This validation must happen in real-time before the account is inserted into the
system. Additionally, the developer wants to prevent the consumption of unnecessary SME
statements.

What is the optimal way to meet this requirement?

Answer: Make a callout to the web service from a custom Visualforce controller.

Question: A company has a web page that needs to get Account record information, such as name,
website, and employee number. The Salesforce

record ID is known to the web page and it uses JavaScript to retrieve the account information.

Which method of integration is optimal?

Answer: REST API / Apex Rest Web Service

Question: What is the optimal technique a developer should use to programmatically retrieve Global
Picklist options in a test method?

Answer: Use the schema namespace.

Question: A company wants to run different logic based on an opportunity's record type.

Which code segment handles this request and follows best practices?

Answer:

Id recType_New =

Schema. SobjectType. Opportunity.getRecordTypeInfosByDeveloperName().get('w').getRecordtypeid


{

Id recType_Renewal =

Schema. SobjectType. Opportunity.getRecordType Infos By


Developerttame().get('Renewal').getRecordTyp
Or

List<recordType> recTypes = [SELECT Id, Name FROM RecordType WHERE sobjectType =


'Opportunity' AND IsActive = True];

Map<string,id> recTypeMap = new Map<string,id> ();

for (RecordType rt : recTypes) {

recTypeMap.put(rt.Name, rt. Id);

for (Opportunity o: Trigger.new) {

if (0. Record TypeId == recTypeMap.get('New') {

// do some logic Record Type 1

Question: A developer is trying to access org data from within a test class.

Which sObject type requires the test class to have the (see AllData=true) annotation?

Answer: Report

Question: In an organization that has multi-currency enabled, a developer is tasked with building a
Lighting component that displays the top ten Opportunities most recently accessed by the logged in
user. The developer must ensure the amount and Last ModifiedDate field values are displayed
according to the user's locale.

What is the most effective approach to ensure values displayed respect the user's locale settings?

Answer: Use the FORMAT() function in the SOQL query.

Question: Universal Containers implements a private sharing model for the Convention_Attendee_e
custom object. As part of a new quality assurance

effort, the company created an Event_Reviewer__c user lookup field on the object. Management
wants the event reviewer to automatically gain Read/Write access to every record they are assigned
to.

What is the best approach to ensure the assigned reviewer obtains Read/Write access to the record?

Answer: Create an After Insert trigger on the Convention Attendee custom object, and use Apex
Sharing Reasons and Apex Managed Sharing

Question:
<lightning:button label="Save" onclick="{!c.handleSave}"/>

({

handleSave : function (component, event, helper) {

helper. saveAndRedirect (component);

})

A company has the Lightning Component above that allows users to click a button to save their
changes and redirects them to a different page. Currently, when the user hits the Save button the
records are getting saved, but they are not redirected.

Which three techniques can a developer use to debug the JavaScript? Choose 3 answers

Answer: Enable Debug Mode for Lightning components for the user.

Use the browser's dev tools to debug the JavaScript.

Use console.log() messages in the JavaScript.

Question:

Refer to the markup below:

<Template>

<!---- other code ----- >

<lightning-record-form

record-id={recordId}

object-api-name="Account"

layout-type="Full">

</lightning-record-form>

</template>

A Lightning web component displays the Account name and two custom fields out of 275 that exist on
the object. The custom fields are correctly declared and populated. However, the developer receives
complaints that the component performs slowly.

What can the developer do to improve the performance?


Answer: Replace layout-type="Full" with fields={fields}

Question: A managed package uses a list of country ISO codes and country names as reference data
in many different places from within the managed

package Apex code.

What is the optimal way to store and retrieve the list?

Answer: Store the information in custom metadata and access it with the getall() method.

Question: Which interface needs to be implemented by an Aura component so that it may be


displayed in modal dialog by clicking a button on a Lightning record page?

Answer: force: lightning QuickAction

Question:

@isTest

Static void testMyTrigger() {

//Do a bunch of data setup

Datafactory.setupDataForMyTriggerTest();

List<Account> acctsBefore = [Select Is_Customer__c FROM Account where id in :


Datafactory.Accounts];

//Utility to asser all accounts are not customers before the update

AssertUtil.assertNotCustomers(acctBefore);

For(Account a : Datafactory.accounts)

a.Is_Customer__c=true;

Update Datafactory.accounts;

List<Account> acctsAfter = [select Number_Of_Transfers__c from account where id in


:DataFactory.accounts];

//Utility to assert Number_of _ Transfers__c is correct based on data

AssertUtil.assertNumberOfTransfers(acctsAfter);

The test method above tests an Apex trigger that the developer knows will make a lot of queries when
a lot of Accounts are simultaneously updated to be customers.

The test method fails at the line 20 because of too many soql queries.
Answer: Add Test.startTest() before line 18 of the code and add Test.stopTest() after line 18 of the
code.

Question: A developer created a Lightning web component that uses a lightning-record-edit-form to


collect information about Leads. Users complain that they only see one error message at a time about
their input when trying to save a Lead record.

What is the recommended approach to perform validations on more than one field, and display
multiple error messages simultaneously with minimal JavaScript intervention?

Answer: External JavaScript library

Question: company uses their own custom-built enterprise resource planning (ERP) system to handle
order management. The company wants 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 has shipped.

Which two methods can make this ERP order data visible in Salesforce? Choose 2 answers

Answer: Use Salesforce Connect to view real-time Order data in the ERP system

Have the ERP system push the data into Salesforce using the SOAP API.

Question: Which three approaches should a developer implement to obtain the best performance for
data retrieval when building a Lightning web component? Choose 3 answers

Answer: Use lazy load for occasionally accessed data.

Use the Lightning Data Service.

Use (Cacheable=true) whenever possible.

Question: Which tag should a developer use to display different text while an <apex:commandButton>
processing an action?

Answer: <apex:actionstatus>

Question: An org has a requirement that an Account must always have one and only one Contact
listed as Primary. So, selecting one Contact will de-select any others. The client wants a checkbox on
the Contact called 'Is Primary' to control this feature. The client also wants to ensure that the last
name of every Contact is stored entirely in uppercase characters.

What is the optimal way to implement these requirements?

Answer: Write a single trigger on Contact for both after update and before update and callout to
helper classes to handle each set of logic.

Question: Consider the controller code below that is called from an Aura component and returns data
wrapped in a class.

public class myserverSideController {

@AuraEnabled
Public static MyDataWrapper getSomeData { String theType) {

Some_Object_c someobj =[ SELECT ID, Name FROM Some_object_c WHERE Type__C =: theType
LIMIT 1 ];

Another_object_c anotherobj = [ SELECT ID, option_c FROM Another object_c WHERE


Some_object_C-=:someobj.Name LIMIT 1 ];

MyDatawzapper theData = new MyDataWrapper();

theData.Name -=someobj. Name;

theData.option = anotherobj.option_c;

return theData;

public class MyDataWrapper {

public String Name {get; set;}

The developer verified that the queries return a single record each and there is error handling in the
Aura component, but the component is not getting anything back when calling the controller get some
Data. What is wrong?

Answer: The member's Name and option of the class MyDataWrapper should be annotated with
@AuraEnabled also.

Question: Which scenario requires a developer to use an Apex callout instead of Outbound
Messaging?

Answer: The target system uses a REST API.

Question: A developer wants to write a generic Apex method that will compare the Salesforce Name
field between any two object records. For example, to compare the Name field of an Account and an
opportunity; or the Name of an Account and a Contact

Assuming the Name field exists, how should the developer do this?

Answer: Cast each object into an sObject and use sobject.get('Name') to compare the Name fields.

Question: Which use case can be performed only by using asynchronous Apex?

Answer: Calling a web service from an Apex trigger

Question: 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 the contact records that have no 'Fulfilled' Orders?

Answer: SELECT Id FROM Contact WHERE ID NOT IN (SELECT Contact__c FROM Order__c
WHERE

status_c =’Fulfilled’)
Question: A developer wants to integrate invoice and invoice line data into Salesforce from a custom
billing system. The developer decides to make real-time callouts from the billing system using the
SOAP API. Unfortunately, the developer is getting a lot of errors when inserting the invoice line data
because the invoice header record does not exist yet.

What will help ensure the transactional integrity of the Integration?

Answer: Create the invoice header and the related invoice lines in the same create() call leveraging
External Ids.

Question: A company has a custom object, Order_c, that has a required, unique external ID field
called Order_Number__c.

Which statement should be used to perform the DML necessary to insert new records and update
existing records in a list of Order_c records using the external ID field?

Answer: upsert orders Order_Number_c:

Question: What are three reasons that a developer should write Jest tests for Lightning web
components? Choose 3 answers

Answer: To test basic user interaction

To verify that events fire when expected

To verify the DOM output of a component

Question: A developer created and tested a Visualforce page in their developer sandbox, but now
receives reports that user encounter view state errors when using it in production.

What should the developer ensure to correct these errors?

Answer: Ensure variables are marked as transient.

Question: What are three benefits of using static resources in Visualforce and Aura components?

Choose 3 answers

Answer:

Static resource files can be referenced by using the @Resource global variable instead of
hardcoded IDs.

Static resource files can be packaged into a collection of related files in a zip or jar archive.

Relative paths can be used in files in static resource archives to refer to other content
within the archive.

Question: Salesforce users consistently receive a "Maximum trigger depth exceeded" error when
saving an Account.

How can a developer fix this error?


Answer: Use a helper class to set a Boolean to TRUE the first time a trigger is fired, and then modify
the trigger to only fire when the Boolean is FALSE.

Question: A company has a custom component that allows users to search for records of a certain
object type by invoking an Apex Controller that returns a list of results based on the user's input.
When the search is completed, a search Complete event is fired, with the results put in a results
attribute of the event. The component is designed to be used within other components and may
appear on a single page more than once.

What is the optimal code that should be added to fire the event when the search has completed?

Answer: var evt =$A.get("e.c.searchComplete");

evt.setParams ([results: results]);

evt.fire();

Question: A developer wrote a test class that successfully asserts a trigger on Account. It fires and
updates data correctly in a sandbox environment.

A Salesforce admin with a custom profile attempt to deploy this trigger via a change set into the
production environment, but the test class fails with an insufficient privileges error.

What should a developer do to fix the problem?

Answer: Add system.runast() to the test class to execute the trigger as a user with the correct object

permissions.

Question: Given a list of Opportunity records named opportunity List, which code snippet is best for
querying all Contacts of the Opportunity's Account?

Answer:

List <Contact> contactList = new List Contact>();

Set <Id> accountIds - new Set ();

for (Opportunity o: opportunitylist) {

accountIds.add(o.AccountId);

for (Account a: [SELECT id, (SELECT ID FROM Contacts) FROM Account WHERE ID IN :
accountIds]){

contactList.addAll(a.Contacts):

}
Question: 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?

Answer: Decorate the server-side method with @AuraEnabled (cacheable=true).

Question: Given the following containment hierarchy:

<! - - myParentComponent.html - - >

<template>

<c-my-child-component></ c-my-child-component>

</template>

What is the correct way to communicate the new value of a property named "passthrough to my-
parent-component if the property is defined within my-child-component?

Answer: let cEvent = new customEvent('passthrough', { detail: this.passthrough });

this.dispatchEvent (cEvent);

Question:

@isTest

static void testUpdateSuccess() {

Account acct = new Account (Name = 'test')

insert acct;

// Add code here

extension.inputValue = 'test;

PageReference pageRef = extension.update();

System.assertNotEquals(null, pageRef);

What should be added to the setup, in the location indicated, for the unit test above to create the
controller extension for the test?

Answer:

ApexPages. StandardController sc = new ApexPages.standardController (acct);

AccountControllerExt extension = new AccountControllerExt(sc);

Question: Part of a custom Lightning Component displays the total number of Opportunities in the org,
which is in the millions. The Lightning Component uses an Apex Controller to get the data it needs.

What is the optimal way for a developer to get the total number of Opportunities for the Lightning
Component?
Answer: COUNT() SOQL aggregate query on the Opportunity object

Question:

Universal Containers (UC) wants to develop a customer community to help their customers log issues
with their containers. The community needs to function for their German- and Spanish-speaking
customers also. UC heard that it's easy to create an international community using Salesforce, and
hired a developer to build out the site.

What should the developer use to ensure the site is multilingual?

Answer: Use Custom Labels to ensure custom messages are translated properly.

Question: A company wants to implement a new call center process for handling customer service
calls. The new business process requires Service Representatives to ask the calling customer for
their account number before proceeding with the rest of the call script.

Following best practices, what should be used to meet this requirement?

Answer: Flow Builder

Question: How should a developer assert that a trigger with an asynchronous process has
successfully run?

Answer: Create all test data in the test class, invoke Test.startTest) and Test.stopTest() and then
perform assertions.

Question: 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 endpoint?

Choose 2 answers

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

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.

Question: There are user complaints about slow render times of a custom data table within a
Visualforce page that loads thousands of Account records at once.

What can a developer do to help alleviate such issues?

Answer: Use the standard Account List controller and implement pagination
Question: 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.

import LightningElement from 'lwc';

import getData from 'salesforce/apex/AccountInfo.getData';

export default class Account Info extends LightningElement {

account;

name;

nameChanged (evt) {

this.name = evt. target.value;

loadData() {}

Component Markup Snippet:

<lightning-button label=”Load data” onclick={loaddata} > </lightning-button>

<lightning-input type=”text” label=”Name” value={name} onchange={nameChanged}></lightning-


input>

What must be added to get the data?

Answer: Add getDataname({ this.name}). then (result => this.account = result; }); to the loadData()
function.

Question: A developer wants to call an Apex server-side controller from an Aura component.

What are two limitations to the data being returned by the controller? Choose 2 answers

Answer: Basic data types are supported, but defaults, such as maximum size for a number, are
defined by the objects that they map to.

A custom Apex class can be returned, but only the values of public instance properties and method
annotated with Aura Enabled are serialized and returned.

Question: Universal Containers uses Big Objects to store almost a billion customer transactions called
Customer_Transaction_b.

These are the fields on Customer_Transaction_b:

Account_c

Program_c

Points_Earned_c

Location_c

Transaction_Date__c
The following fields have been identified as Index Fields for the Customer_Transaction_b object:
Account__c, Program__c, and Transaction_Date_c.

Which SOQL query is valid on the Customer_Transaction_b Big Object?

Answer: SELECT Account_c, Program_c, Transaction_Date_c FROM Customer_Transaction__c


WHERE Account_c=’ 001R00000030203’ AND Program_c=’Shoppers’ AND
Transaction_Date_c=2019-05-31T00:00Z

Question: The Account edit button must be overridden in an org where a subset of users still use
Salesforce Classic. The org already has a Lightning Component that will do the work necessary for
the override, and the client wants to be able to reuse it.

How should a developer implement this?

Answer: Override the edit button for Lightning with a Lightning Component; and for Classic, override
the edit button with a Visualforce page that contains the Lightning Component.

Question: A developer is creating a Lightning web component that can be added to a Lightning App
Page and displayed when the page is rendered in desktop and mobile phone format. To ensure a
great mobile experience, the developer chooses to use the SLDS grid utility.

Which two Lighting web components should the developer implement to ensure the application is
mobile-ready?

Choose 2 answers

Answer: <lightning-layout></lightning-layout>

<lightning-layout-item></lightning-layout-item>

Question: A company's support process dictates that any time a Case is closed with a Status of
'Could not fix,' an Engineering Review custom object record should be created and populated with
information from the case, the Contact, and any of the Products associated with the case.

What is the correct way to automate this using an Apex trigger?

Answer: An after update trigger that creates the Engineering Review record and inserts it

Question: Which statement is true regarding savepoints?

Answer: Static variables are not reverted during a rollback

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

How should the developer access the data that must be displayed?

Answer: Execute a SOQL query for Amount, Probability, Stage, and close Date on the Opportunity
History object
Question: A developer is building a Lightning web component that displays quantity, unit price, and
the total for an order line item. The total is calculated dynamically as the quantity multiplied by the unit
price.

JavaScript:

import ( LightningElement } from 'lwc';

export default class OrderLineItem extends LightningElement {

@api quantity;

@api unitPrice;

Template Markup:

<template>

<div>

Quantity : {quantity} <br/>

Unit Price:{unitPrice} <br/>

</template>

What must be added to display the total?

Answer: Add get total() { return quantity * unitPrice; ) to the JavaScript and Total: [total] in the
template

Question: Universal Containers allows customers to log into a Salesforce Community and update their
orders via a custom Visualforce page. Universal Containers' sales representatives can edit the orders
on the same Visualforce page.

What should a developer use in an Apex test class to test that record sharing is enforced on the
Visualforce page?

Answer: Use System.runAs() to test as a sales rep and a community user.

Question: 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 tasks no longer do so.

Which two statements are true regarding these issues and resolution?

Choose 2 answers

Answer: 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 own Change Sets over each other, thus replacing entire Page
Layouts and Workflows in Production.
Question: 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 platform event that makes a callout to the web application

Question: A developer is trying to decide between creating a Visualforce component or a Lightning


component for a custom screen.

Which functionality consideration impacts the final decision?

Answer: Does the screen need to be rendered as a PDF without using a third-party application

Question: Assuming the CreateOneAccount class creates one account and implements the
Queueable interface, which syntax properly tests the Apex code?

Answer:

List<Account> accts;

Test.startTest();

System.enqueueJob ( new CreateOneAccount());

Test.stopTest();

accts = [SELECT ID FROM Account];

System.assertEquals( 1, accts.size() );

Question: A developer is inserting, updating, and deleting multiple lists of records in a single
transaction and wants to ensure that any error prevents all execution.

How should the developer implement error exception handling in their code to handle this?

Answer: Use Database. set Savepoint() and Database.rollBack () with a try-catch statement.

Question: For compliance purposes, a company is required to track long-term product usage in their
org. The information that they need to log will be collected from more than one object and, over time,
they predict they will have hundreds of millions of records.

What should a developer use to implement this?

Answers: Big Objects

Question: A company has a native ios order placement app that needs to connect to Salesforce to
retrieve consolidated information from many different objects in a JSON format.

Which is the optimal method to implement this in Salesforce?

Answer: Apex REST web service


Question: A developer is writing a Visualforce page that queries accounts in the system and presents
a data table with the results. The users want to be able to filter the results based on up to five fields,
that will vary according to their selections when running the page.

Which feature of Apex code is required to facilitate this solution?

Answer: Dynamic Schema binding

Question: Universal Containers has an Apex trigger on Account that creates an Account Plan record
when an Account is 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 updated with today's date.

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?

Answer: The Apex trigger does not use a static variable to ensure it only fires once.

Question: A developer gets an error saying 'Maximum Trigger Depth Exceeded."

What is a possible reason to get this error message?

Answer: A trigger is recursively invoked more than 16 times.

Question: 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 analyse and diagnose the problem in the Lightning Page?

Answer: Salesforce Lightning Inspector Storage Tab

Question: Which method should be used to convert a Date to a string in the current user's locale?

Answer: Date.format

Question: A company accepts orders for customers in their enterprise resource planning (ERP)
system that must be integrated into Salesforce as Order__c records with a lookup field to Account.
The Account object has an external ID field, ERP_Customer_ID__c.

What should the integration use to create new Order_c records that will automatically be related to the
correct Account?

Answer: Upsert on the Order_c object and specify the ERP_Customer_ID__c for the Account
relationship.

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

Answer: Boolean show = User_Prefs__c.getValues (UserInfo.getUserId()).show_Help__c;


Question: Which two queries are selective SOQL queries and can be used for a large data set of
200,000 Account records?

Choose 2 answers

Answer: SELECT ID FROM Account WHERE IS IN (List of Account Ids)

SELECT ID FROM Account WHERE Name IN (List of Names) AND Customer_Number_c


=’ValueA’

Question: @istest

static void testIncrement() {

Account acct = new Account (Name = 'Test');

acct.Number_of_Times_Viewed_c = 0;

insert acet;

AuditUtil.incrementViewed (acet.Id);

Account acctAfter = [SELECT Number_of_Times_Viewed__c

FROM Account WHERE Id = :acct.Id] [0];

System.assertEquals(1, acctAfter. Number_of_Times_Viewed__c);

The test method above calls an @future method that increments the Number_of_Times_Viewed_c
value. The assertion is failing because the Number_of_Times_Viewed__c equals 0.

What is the optimal way to fix this?

Answer: Add Test.starttest() before and Test.stopTest() after AuditUtil. incrementViewed

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

Answer: Application Event

Question: A developer is developing a reusable Aura component that will reside on an sObject
Lightning page with the following HTML snippet:

<aura: component implements="force:hasRecordid, flexipage:availableForAllPageTypes">

<div>Hello! </div>

</aura:component>

How can the component's controller get the context of the Lightning page that the sobject is on
without requiring additional test coverage?

Answer: Add force:hasSobjectName to the implements attribute


Question: 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 in the industry select list, the table of Accounts should be
automatically updated to show the Accounts associated with the selected industry.

What is the optimal way to implement this?

Answer: Add an <apex:actionSupport> within the <apex:selectList>

Question: Refer to the Aura component below:

Component markup:

<aura:component>

<aura:attribute name=”contactInfo” type=”object”/>

<aura:attribute name=”showcontactInfo” type=”boolean” default=”true”/>

<aura:handler name=”init” valu=”{!this}” action=”{!c.init}”/>

<! - - - Other Side - - ->

<aura:if isTrue=”{!v.showContactInfo}”>

<c:contactInfo value=”{!v.contactInfo}”/>

</aura:if>

</aura:component>

Controller JS:

({

init: function(cmp, helper) {

// ... other code ...

var show = helper.getShowContactInfo();

cmp.set("v.showContactinfo", show);

},

// other code...

})

A developer receives complaints that the component loads slowly.

Which change can the developer implement to make the component perform faster?

Answer: Change the default for showContactInfo to "false".


Question: Which code statement includes an Apex method named updateAccounts in the class
AccountController for use in a Lightning web component?

Answer: import updateAccounts from ‘@salesforce/apex/AccountController.updateAccounts';

Question: What are two benefits of using External IDs?

Choose 2 answers

Answer: An External ID field can be used to reference a unique ID from another, external system

An External ID is indexed and can improve the performance of SOQL queries

Question: The use of the transient keyword in Visualforce Page Controllers helps with which common
performance issue?

Answer: Reduces View State

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

Choose 2 answers

Answer: Specify the target to be lightning_RecordPage.

Set the IsExposed attribute to true

Question: A developer has working business logic code, but sees the following error in the test class:
You have uncommitted work pending. Please commit or rollback before calling out.

What is a possible solution?

Answer: Use test. IsRunningTest () before making the callout to bypass it in test execution.

Question: The Contact object in an org is configured with 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?

Answer: INFO level for the Workflow log category

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

Answer: A Continuation for both the billing callout and the tax callout

Question: How should a developer verify that a specific Account record is being tested in a test class
for a Visualforce controller?

Answer: Insert the Account in the test class, instantiate the page reference in the test class, then use
System.current Page Reference().getParameters() .put() to set the Account ID.

Question: Which three actions must be completed in a Lightning web component for a JavaScript file
in a static resource to be loaded?

Choose 3 answers

Answer: Import a method from the platformResourceLoader

Import the static resource

Call loadscript

Question: 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 are 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?

Answer: Use a hierarchy custom setting to skip executing the logic inside the trigger for the user who
loads the data

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

Answer: Use an Email Alert with Process Builder.

Question: A company notices that their unit tests in a test class with many methods to create many
records for prerequisite reference data are slow.

What can a developer to do address the issue?

Answer: Move the prerequisite reference data setup to a TestDataFactory and call that from each test

method.

Question: Consider the Apex controller below, that is called from an Aura component.

Line 1 public class Attribute Types


Line 2 {

Line 3 private final String[] arrayItems;

Line 4

Line 5 @Aura Enabled

Line 6 public List <string> getStringArray () {

Line 7 String[] arrayItems = new String[] { 'red', 'green', 'blue' };

Line 8 return arrayItems;

Line 9 }

Line 10 }

What is wrong with this code?

Answer: Line 6: method must be static

Question: A company decides that every time an opportunity is created, they want to create a follow
up Task and assign it to the Opportunity owner.

What should be used to implement the requirements?

Answer: Process Builder on Opportunity

Question: Universal Containers wants to use a Customer Community with Customer Community Plus
licenses to allow their customers access to track how many containers they have rented and when
they are due back. Universal Containers uses a Private sharing model for External users.

Many of their customers are multi-national corporations with complex Account hierarchies. Each
account on the hierarchy represents a department within the same business.

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 that represent the departments.

Which solution solves these requirements

Answer: An Apex trigger that creates Apex managed sharing records based on the junction object's
relationships

Question: As part of their quoting and ordering process, a company needs to send PDFs to their
document storage system's REST endpoint that supports OAuth 2.0. Each Salesforce user must be
individually authenticated with the document storage system to send the PDF.

What is the optimal way for a developer to implement the authentication to the REST endpoint?

Answer: Named Credential with an Auth Authentication Provider

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

Answer: Implement the logic in a helper class that is called by an Apex trigger on Contact and from
the Custom Visualforce page controller

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

Answer: Create an Apex trigger, execute a Queueable job from it, and make a callout from the
Queueable job.

Question: A Visualforce page loads slowly due to the large amount of data it displays.

Which strategy can a developer use to improve the performance?

Answer: Use lazy loading to load the data on demand, instead of in the controller's constructor.

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

Answer: Visualforce

Question: A developer is writing code that requires making callouts to an external web service.

Which scenario necessitates that the callout be made in an @future method?

Answer: The callouts will be made in an Apex Trigger

Question: 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 updated records.

public void updateAndMakeCallout (Map<id,Request__c> reqs, Map<id,Request_line__c> reqLines)


{

Savepoint sp = Database.setSavepoint();

Try {

insert regs.values();

insert reglines.values();

HttpResponse response -=CalloutUtil.makeRestCallout (reqs.keySet(), reqlines.keySet(); }

catch (Exception e) {
Database.rollback(sp);

System.debug(e);

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?

Answer: Change the CalloutUtil.makeRestCallout to an future method

Question: What is the best practice to initialize a Visualforce page in a test class?

Answer: Use Test.setCurrentPage(Page.MyTestPage);

Question: A page throws an 'Attempt to dereference a null object' error for a Contact

What change in the controller will fix the error?

Answer: Use a condition in the getter to return a new Contact if it is null

Question: @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__ FROM Account WHERE Id = :acct.Id][0]];

System.assert(true, acctAfter.Integration_Updated__c);

The test method above 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?

Answer: Add Test.startTest() and Test.setMock before and Test.stopTest() after


CalloutUtil.sendAccountUpdate.

Question: A corporation has many different Salesforce orgs, with some different objects and some
common objects, and wants to build a single Java application that can create, retrieve, and update
common object records in all of the different orgs.

Which method of integration should the application use?


Answer: SOAP API with the Partner WSDL

Question: Refer to the following code snippets:

MyOpportunities.js

import { Lightningelement, wire } from 'lwc';

import getOpportunities from ‘@salesforce/apex/OpportunityController.findMyOpportunities';

export default class MyOpportunities extends LightningElement {

@api userid;

@wire (getOpportunities, {oppOwner: 'SuserId'})

opportunities;

Opportunity Controller.cls

public with sharing class OpportunityController {

@AuraEnabled

public static List<Opportunity> findmyOpportunities (Id oppOwner){

return [

SELECT id, Name, Amount FROM Opportunity WHERE OwnerId = : oppOwner WITH
SECURITY_ENFORCED LIMIT 10];

A developer is experiencing issues with a Lightning web component. The component must surface
information about Opportunities owned by the currently logged-in user.

When the component is rendered, the following message is displayed: "Error retrieving data".

Which modification should be implemented to the Apex class to overcome the issue?

Answer: Use the Cacheable=true attribute in the Apex method

Question: 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>
How should a developer change the component to be responsive for mobile and tablet devices?

Answer: <lightning:layout multiplerows=”true”>

<lightning:layoutItem size=”12” largeDeciceSize=”6”>{!v.rec.Name}

</lightning:layoutItem>

< lightning:layoutItem size=”12” largeDeciceSize=”6”>{!v.rec.Description__c}

</lightning:layoutItem>

</lightning:layout>

Question: What is a benefit of using a WSDL with Apex?

Answer: Allows for classes to be generated from WSDL and imported into Salesforce

Question:

You might also like