A business currently has a labor-intensive process to manually upload orders from an external OMS. Accounts must be exported to get IDs to link the orders. Which two recommendations should make this process more efficient?
Correct Answer: C,D
The current bottleneck is caused by the need to resolve Salesforce Internal IDs ($001...$) for the Account lookup before orders can be imported. This can be completely bypassed by using External IDs (Option D) and the Upsert operation (Option C). * External IDs: By marking a unique field from the OMS (like OMS_Account_Number__c) as an External ID in Salesforce, the developer creates a "foreign key" that Salesforce understands. * Upsert Wizard: When using the Data Loader's Upsert wizard, the user is asked which field should be used to match the parent Account. By selecting the OMS_Account_Number__c external ID, the Data Loader allows the user to map the orders directly to accounts using the OMS number found in the CSV file. Salesforce will automatically find the correct Account ID in the background. This eliminates the "export-and- VLOOKUP" step entirely. Option A (Insert) would still require internal IDs. Option B (sorting) helps with performance in massive loads but doesn't solve the manual ID matching problem. Using Upsert with External IDs is the platform-recommended way to streamline recurring data integrations.
PDII Exam Question 37
A developer creates an application event that has triggered an infinite loop. What may have caused this problem?
Correct Answer: B
In the Aura Component Framework, an infinite loop involving an application event is frequently caused by firing the event from a custom renderer (Option B), specifically from the afterRender or rerender functions. The framework's rendering lifecycle is sensitive. When a component's state changes, the renderer is invoked to update the DOM. If a developer places code inside a renderer that fires an application event, and that event-or a handler of that event-subsequently modifies an attribute on the same component, the component is marked as "dirty." This triggers the renderer to run again, which fires the event again, creating an infinite loop. Option A is incorrect because multiple handlers simply result in multiple independent blocks of code executing, not a loop. Option C relates to touch events on mobile but wouldn't cause a loop unless the handler itself re-triggered the event. Option D is incorrect because triggers are server-side and do not directly re-fire client-side application events in a looping fashion. To avoid this, event firing should be restricted to controller or helper actions that are triggered by specific user interactions or discrete system states, rather than the automatic rendering cycle.
PDII Exam Question 38
The test method calls an @future method that increments a value. The assertion is failing because the value equals 0. What is the optimal way to fix this? Java @isTest static void testIncrement() { Account acct = new Account(Name = 'Test', Number_Of_Times_Viewed__c = 0); insert acct; AuditUtil.incrementViewed(acct.Id); // This is the @future method Account acctAfter = [SELECT Number_Of_Times_Viewed__c FROM Account WHERE Id = :acct.Id][0]; System.assertEquals(1, acctAfter.Number_Of_Times_Viewed__c); }
Correct Answer: D
Asynchronous methods, such as those annotated with @future, do not run immediately when called in Apex. Instead, they are added to a queue to be processed when system resources become available. In a unit test, if you call a future method and immediately query the database for the result, the future method likely hasn't executed yet, resulting in the "0" value observed in the assertion. To test asynchronous code, you must wrap the call within Test.startTest() and Test.stopTest() (Option D). When the code reaches Test.stopTest(), the execution of the test script pauses, and the system forces all queued asynchronous jobs (future methods, batch jobs, queueable jobs) to run to completion synchronously. By placing the AuditUtil.incrementViewed(acct.Id) call inside this block, you ensure that by the time the next line of code (the SOQL query) runs, the increment logic has finished and the database reflects the new value. Option B is incorrect because inserting the account is a synchronous operation that doesn't require the stopTest wait. Option A and C avoid the problem rather than testing the logic correctly. Option D is the standard platform-required pattern for testing asynchronous side effects.
PDII Exam Question 39
A Salesforce org has more than 50,000 contacts. A new business process requires a calculation that aggregates data from all of these contact records. This calculation needs to run once a day after business hours. Which two steps should a developer take to accomplish this?
Correct Answer: B,C
This scenario presents two distinct requirements: processing a large volume of data (50,000 records) and running the process at a specific time (once a day after business hours). * Database.Batchable (Option B): Processing 50,000 records in a single synchronous transaction will exceed Apex Governor Limits (specifically the CPU time limit or the heap size limit). Batch Apex allows the system to process these records in smaller chunks (batches), ensuring that the calculation completes without hitting limits. * Schedulable (Option C): To ensure the job runs "once a day after business hours," the Schedulable interface is required. The developer allows the class to be scheduled via the Apex Scheduler or the UI. The standard pattern for this use case is to create a class that implements Schedulable, and inside its execute method, instantiate and execute the Batch class (Database.executeBatch). This combines precise timing with bulk processing capabilities.
PDII Exam Question 40
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?
Correct Answer: B
When developing custom functionality to be surfaced within the standard Salesforce Mobile App, Lightning Web Components (LWC) (Option B) is the recommended approach. LWCs are the modern, high- performance standard for Salesforce development, utilizing modern web standards (ES6+, Web Components) that run natively in the browser. LWC is preferred over the other options for several reasons: * Performance: LWCs are lightweight and provide a much faster, more responsive user interface than Visualforce (Option D), which is critical for mobile user experience. * Standardization: Since the app will be accessed via the standard Salesforce mobile app, LWCs integrate seamlessly into the mobile navigation, tabs, and action menus. * Customization: LWCs provide full control over the CSS and HTML, allowing the developer to meet the "custom user interface design" requirement while still leveraging the Lightning Data Service for efficient data handling. Option A (Salesforce SDK) is for building "Custom/Native" standalone apps, not for extending the standard Salesforce app. Option C (Experience Builder) is primarily for external sites (Communities). LWC provides the perfect balance of "custom design" and "native integration" for internal mobile users.