A company has an Apex process that makes multiple extensive database operations and web service callouts. The database processes and web services can take a long time to run and must be run sequentially. How should the developer write this Apex code without running into governor limits and system limitations?123
A business requires that every parent record must have a child record. A developer writes an Apex method with two DML statements to insert a parent record and a child record. A validation rule blocks child records from being created. The method uses a try/catch block to handle the DML exception. What should the developer do to ensure the parent always has a child record?
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?
Universal Containers wants to develop a recruiting app for iOS and Android via the standard Salesforce mobile app. It has a custom user interface design and offline access is not required. What is the recommended approach to develop the app?
A developer created an Apex class that updates an Account based on input from a Lightning web component. The update to the Account should only be made if it has not already been registered.
Java
account = [SELECT Id, Is_Registered__c FROM Account WHERE Id = :accountId];
if (!account.Is_Registered__c) {
account.Is_Registered__c = true;
// ...set other account fields...
update account;
}
What should the developer do to ensure that users do not overwrite each other’s updates to the same Account if they make updates at the same time?
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?
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?12
Refer to the code snippet below:
Java
public static void updateCreditMemo(String customerId, Decimal newAmount){
List
for(Credit_Memo__c creditMemo : [Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50]) {
creditMemo.Amount__c = newAmount;
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, the developer needs to ensure race conditions are prevented when a set of records are mod1ified within an Apex transaction. In the preceding Apex code, how can the developer alter the que2ry statement to use SOQL features to prevent race conditions within a tr3ansaction?4
Consider the following code snippet:
HTML
Users of this Visualforce page complain that the page does a full refresh every time the Search button is pressed. What should the developer do to ensure that a partial refresh is made so that only t13he section identified with opportunityList is re-drawn on the screen?1415
Which code snippet processes records in the most memory efficient manner, avoiding governor limits such as "Apex heap size too large"?
A Salesforce developer is hired by a multi-national company to build a custom Lightning application that shows employees their employment benefits and earned commissions over time. The application must acknowledge and respect the user's locale context for dates, times, numbers, currency, and currency symbols. When using Aura components, which approach should the developer implement to ensure the Lightning application complies with the user's locale?3
A developer needs a Lightning web component to display in one column on phones and two columns on tablets/desktops. Which should the developer add to the code?
An Apex trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. A developer is tasked with preventing Contract records from being created when mass loading historical Opportunities, but the daily users still need the logic to fire. What is the most extendable way to update the Apex trigger to accomplish this?
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?161718
Which select statement should be inserted to retrieve Tasks ranging from 12 to 24 months old, including archived tasks, and excluding deleted ones?
Java
Date initialDate = System.Today().addMonths(-24);
Date endDate = System.Today().addMonths(-12);
Business rules require a Contact to always be created when a new Account is created. What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?
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 LastModifiedDate 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?1819
A Salesforce Platform Developer is leading a team that is tasked with deploying a new application to production. The team has used source-driven development, and they want to ensure that the application is deployed successfully. What tool or mechanism should be used to verify that the deployment is successful?
What is a benefit of JavaScript remoting over Visualforce Remote Objects?
What are three reasons that a developer should write Jest tests for Lightning web components?
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?1234567
Refer to the following code snippet:
Java
public class LeadController {
public static List
String safeTerm = '%'+searchTerm.escapeSingleQuotes()+ '%';
return [
SELECT Name, Company, AnnualRevenue
FROM Lead
WHERE AnnualRevenue >= :aRevenue
AND Company LIKE :safeTerm
LIMIT 20
];
}
}
A developer created a JavaScript function as part of a Lightning web component (LWC) that surfaces information about Leads by wire calling getFetchLeadList when certain criteria are met. Which three changes should the developer implement in the Apex class above to ensure the LWC can display data efficiently while preserving security?1
Universal Containers develops a Visualforce page that requires the inclusion of external JavaScript and CSS files. They want to ensure efficient loading and caching of the page. Which feature should be utilized to achieve this goal?
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?
Salesforce users consistently receive a "Maximum trigger depth exceeded" error when saving an Account. How can a developer fix this error?
Universal Containers is leading a development team that follows the source-driven development approach in Salesforce. As part of their continuous integration and delivery (CI/CD) process, they need to automatically deploy changes to multiple environments, including sandbox and production. Which mechanism or tool would best support their CI/CD pipeline in source-driven development?
Millions of Accounts are updated every quarter from an external system. What is the optimal way to update these in Salesforce?
Which statement is true regarding savepoints?
A software company uses a custom object, Defect__c, to track defects in their software. Defect__c has organization-wide defaults set to private. Each Defect__c has a related list of Reviewer__c records, each with a lookup field to User that is used to indicate that the User will review the Defect__c. What should be used to give the User on the Reviewer__c record read only access to the Defect__c record on the Reviewer__c record?34
Which use case can be performed only by using asynchronous Apex?
Java
@isTest
static void testUpdateSuccess() {
Account acet = new Account(Name = 'test');
insert acet;
// 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?
Universal Containers uses Salesforce to track orders in an Order__c object. The Order__c object has private organization-wide defaults. The Order__c object has a custom field, Quality_Controller__c, that is a Lookup to User and is used to indicate that the specified User is performing quality control on the Order__c. What should be used to automatically give read only access to the User set in the Quality_Controller__c field?
The Account object has a field, Audit_Code__c, that is used to specify what type of auditing the Account needs and a Lookup to User, Auditor__c, that is the assigned auditor. When an Account is initially created, the user specifies the Audit_Code__c. Each User in the org has a unique text field, Audit_Code__c, that is used to automatically assign the correct user to the Account's Auditor__c field.
Trigger:
Java
trigger AccountTrigger on Account (before insert) {
AuditAssigner.setAuditor(Trigger.new);
}
Apex Class:
Java
public class AuditAssigner {
public static void setAuditor(List
for (User u : [SELECT Id, Audit_Code__c FROM User]) {
for (Account a : accounts) {
if (u.Audit_Code__c == a.Audit_Code__c) {
a.Auditor__c = u.Id;
}
}
}
}
}
What should be changed to most optimize the code's efficiency?
A company wants to allow support managers to see all cases in the org, regardless of who owns them. However, they want to support agents to only see cases they own or cases owned by someone in their role or a subordinate role. Which sharing solution should a developer use to achieve this requirement?
A developer is trying to access org data from within a test class. Which sObject type requires the test class to have the (seeAllData=true) annotation?
A developer sees test failures in the sandbox but not in production. No code or metadata changes have been actively made to either environment since the sandbox was created. Which consideration should be checked to resolve the issue?
A query using OR between a Date and a RecordType is performing poorly in a Large Data Volume environment. How can the developer optimize this?
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?
The test method tests an Apex trigger that the developer knows will make a lot of queries when a lot of Accounts are simultaneously updated. The test method fails at Line 20 because of "too many SOQL queries." What is the correct way to fix this?
Java
Line 12: //Set accounts to be customers
Line 13: for(Account a : DataFactory.accounts)
Line 14: {
Line 15: a.Is_Customer__c = true;
Line 16: }
Line 17:
Line 18: update DataFactory.accounts;
Line 19:
Line 20: List
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 do to address the issue?
Universal Containers wants to notify an external system, in the event that an unhandled exception occurs, by publishing a custom event using Apex. What is the appropriate publish/subscribe logic to meet this requirement?
A Visualforce page loads slowly due to the large amount of data it displays. Which strategy can a developer use to improve the performance?
The Lightning Component allows users to click a button to save their changes and then 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?1
Which three Visualforce components can be used to initiate Ajax behavior to perform partial page updates?
What is the best practice to initialize a Visualforce page in a test class?
A developer creates a lightning web component to allow a Contact to be quickly entered. However, error messages are not displayed.
HTML
Which component should the developer add to the form to display error messages?12
Consider the Apex class below that defines a RemoteAction used on a Visualforce search page.
Java
global with sharing class MyRemoter {
public String accountName { get; set; }
public static Account account { get; set; }
public MyRemoter() {}
@RemoteAction
global static Account getAccount(String accountName) {
account = [SELECT Id, Name, NumberOfEmployees FROM Account WHERE Name = :accountName];
return account;
}
}
Which code snippet will assert that the remote action returned the correct Account?
A developer is asked to find a way to store secret data with an ability to specify which profiles and users can access which secrets. What should be used to store this data?