Which use case can be performed only by using asynchronous Apex?
Correct Answer: C
Asynchronous Apex is a way of executing code in a separate thread from the main execution context. This allows you to perform long-running or resource-intensive operations without blocking the user interface or exceeding the governor limits. Some use cases that can be performed only by using asynchronous Apex are: calling a web service from an Apex trigger, sending email messages, performing complex calculations, and processing large data sets. Querying tens of thousands of records, scheduling a batch process, and updating a record after an insert can be done with synchronous Apex as well, depending on the context and requirements. Reference: [Asynchronous Apex], [Apex Triggers]
PDII Exam Question 62
How should a developer verify that a specific Account record is being tested in a test class for a Visualforce controller?
Correct Answer: A
To verify that a specific Account record is being tested in a test class for a Visualforce controller, a developer should 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. This way, the test class can simulate the behavior of the Visualforce page that receives the Account ID as a URL parameter and passes it to the controller. System.setParentRecordId() and seeAllData=true are not valid methods or annotations in Apex. System.setParentRecordId().get() is not a way to set the Account ID, but to get the ID of the parent record in a master-detail relationship. Reference: [Testing Custom Controllers and Controller Extensions], [System Class]
PDII Exam Question 63
Universal Containers stores user preferences in a hierarchy custom setting, user Prefs_c, with a checkbox field, show _help co. 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?
Correct Answer: B
The correct way to retrieve the show_Help_ c preference for the current user is to use the User Prefs c.getValues(UserInfo.getUserid{)).Show_Help c statement. This statement will return the user-level value of the show_Help_ c field for the current user, if it exists, or the org-level value, if it does not. The User_Prefa_ c.getValuea().Show_Help_ co statement will always return the org-level value, regardless of the user. The User_Prefs_c.getlnstance(].Show Help c statement will return the user-level value of the show_Help_ c field for the current user, if it exists, or null, if it does not. The User Prefs_c.show Melp_c statement will cause a compile-time error, as the show_Help_ c field is not a static property of the User Prefs_c class. Reference: [Custom Settings Methods], [Custom Settings]
PDII Exam Question 64
Given the following information regarding Universal Containers (UC): * UC represents their customers as Accounts in Salesforce. * All customers have a unique Customer__Number_c that is unique across all of UC's systems. * UC also has a custom Invoice c object, with a Lookup to Account, to represent invoices that are sent out from their external system. UC wants to integrate invoice data back into Salesforce so Sales Reps can see when a customer pays their bills on time. What is the optimal way to implement this?
Correct Answer: C
The optimal way to implement the requirement is to create a cross-reference table in the custom invoicing system with the Salesforce Account ID of each Customer and insert invoice data nightly. This way, the developer can use the Salesforce Account ID as the foreign key to associate the invoice data with the correct Account record in Salesforce, and avoid querying the Account object for each invoice record. This can improve the performance and reliability of the data integration, as it reduces the number of queries and the dependency on the Customer Number field. Ensuring Customer Number is an External ID and that a custom field Invoice Number is an External ID and upsert invoice data nightly would not be optimal, as it would still require querying the Account object for each invoice record to match the Customer Number field. Using Salesforce Connect and external data objects to seamlessly import the invoice data into Salesforce without custom code would not be optimal, as it would require the external system to expose the invoice data as an OData service, and also incur additional costs for using Salesforce Connect. Querying the Account Object upon each call to insert invoice data to fetch the Salesforce ID corresponding to the Customer Number on the invoice would not be optimal, as it would be inefficient and prone to errors, especially if the Customer Number field is not unique or indexed. Reference: [Salesforce Connect: Data Integration Platform], [External ID Field]
PDII Exam Question 65
A developer is responsible for formulating the deployment process for a Salesforce project. The project follows a source-driven development approach, and the developer wants to ensure efficient deployment and version control of the metadata changes. Which tool or mechanism should be utilized for managing the source-driven deployment process?
Correct Answer: D
Salesforce CLI with Salesforce DX is a tool or mechanism that can be used to manage the source-driven deployment process. Salesforce CLI is a command-line interface that can be used to create, manage, and deploy Salesforce projects and orgs. Salesforce DX is a set of tools and features that can be used to enable source-driven development, team collaboration, and agile delivery on the Lightning Platform. By using Salesforce CLI with Salesforce DX, the developer can create and use scratch orgs, which are temporary and disposable orgs that can be used for development and testing. The developer can also use version control systems, such as Git, to track and manage the changes in the source code. The developer can also use scripts, commands, and metadata to automate the deployment of the changes to different environments, such as sandbox and production. Salesforce CLI with Salesforce DX can also integrate with other CI/CD tools and services, such as Jenkins, GitLab, or Heroku. Reference: [Salesforce CLI], [Salesforce DX]