Salesforce-Platform-Developer-II Practice Test
Updated On 1-Jan-2026
202 Questions
Universal Containers (UC) has enabled the translation workbench and has translated picklist values. UC has a custom multi-select picklist field, Product__c, on the Account object that allows sales reps to specify which of UC’s products an Account already has. A developer is tasked with writing an Apex method that retrieves Account records, including the Product_c field. What should the developer do to ensure the value of Products__c is in the current user's language?
A. Use tolabel ducts__c) in the fields list of the SOQL query.
B. Set the locale on each record in the SOQL result list.
C. Call the translate method on each record in the SOQL result list.
D. Use the Locale clause in the SOQL query.
Explanation:
When working with translated picklist values in Salesforce (e.g. using the Translation Workbench), the picklist values stored in the database are stored in English (master value). However, when you want to display these values in the current user's language, you need to retrieve the label version of the field — which includes the translation.
The best practice for retrieving translated values in a SOQL query is to use the toLabel() function. This function returns the user-visible label of a picklist or any other translatable field, based on the user's language settings.
🔍 Option Breakdown:
✅ A. Use toLabel(Products__c) in the fields list of the SOQL query.
➜ Correct approach when querying picklist values that may be translated.
➜ toLabel() ensures the retrieved values reflect the user's current language settings.
➜ Works with single and multi-select picklists.
➜ Syntax example:
SELECT Name, toLabel(Products__c) FROM Account
➜ Best practice for displaying translatable picklist values.
❌ B. Set the locale on each record in the SOQL result list.
➜ The locale affects things like number, date, and time formatting, not picklist translations.
➜ This does not affect picklist label translation.
➜ There is no such method to manually set locale on SOQL result records.
❌ C. Call the translate method on each record in the SOQL result list.
➜ Apex has no built-in translate() method for picklist fields.
➜ Translations are handled at the platform/UI level, not by Apex post-processing.
➜ You must query translated values directly using toLabel().
❌ D. Use the Locale clause in the SOQL query.
➜ SOQL does not support a Locale clause.
➜ Locale is inferred automatically from the current user's language/locale setting.
➜ Invalid syntax – will cause SOQL compilation error.
📚 Reference:
Salesforce SOQL toLabel() function documentation
Translation Workbench Overview – Salesforce Help
Universal Containers is leading a development team that follows the source-driven development approach in Salesforce. As part of their continuous integration and delivery (CL/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?
A. Salesforce CLI with Salesforce DX
B. Salesforce Extensions for Visual Studio Code
C. Change Sets
D. Ant Migration Tool
Explanation:
In a source-driven development model, the development team manages their Salesforce code and metadata in a version control system (like Git) and automates deployments through a CI/CD pipeline. The key requirement here is the ability to automatically deploy changes across multiple environments, which includes sandbox and production. This level of automation and control is best supported by tools that integrate well with version control and provide command-line capabilities for scripting deployments.
✅ A. Salesforce CLI with Salesforce DX is the best option here. Salesforce CLI (sfdx) combined with Salesforce DX enables robust support for source-driven development and continuous integration. It provides commands to retrieve and deploy metadata, manage scratch orgs and sandboxes, run tests, and integrate with CI servers like Jenkins, GitHub Actions, or Azure DevOps. Because it's designed for automation and scriptability, it fits perfectly into CI/CD pipelines and supports best practices like modular deployments and test automation.
❌ B. Salesforce Extensions for Visual Studio Code is a powerful developer tool but is primarily intended for local development. While it provides integration with Salesforce DX, it’s not optimized for automation in CI/CD pipelines. It’s more suitable for developers writing and debugging code rather than for automated deployment across environments.
❌ C. Change Sets are a traditional point-and-click deployment mechanism in Salesforce. While they work for moving changes between orgs, they are manual and not suitable for automation, which disqualifies them from meeting CI/CD needs in a source-driven approach. They also lack version control integration and don’t support advanced scripting or test automation.
❌ D. Ant Migration Tool is an older tool that provides command-line deployment capabilities. Although it can be scripted and supports some automation, it does not support the modern source-tracked development model that Salesforce DX does. It lacks the newer capabilities introduced with Salesforce DX, such as scratch orgs, unlocked packages, and improved metadata handling.
✅ Correct Answer: A. Salesforce CLI with Salesforce DX
Reference:
Salesforce Developer Guide: Salesforce DX Developer Guide
Trailhead: CI/CD for Salesforce
An Apex trigger creates an order co record every time an Opportunity is won by a Sales Rep. Recently the trigger is creating two orders. What is the optimal technique for 2 developer to troubleshoot this?
A. Disable all flows, and then re-enable them one at at time to see which one causes the error.
B. Run the Apex Test Classes for the Apex trigger to ensure the code still has sufficient code coverage.
C. Set up debug logging for every Sales Rep, then monitor the logs for errors and exceptions,
D. Add system.debug() statements to the code and use the Developer Console logs to trace the code.
Explanation:
🧠 Scenario Overview:
A trigger is unintentionally creating two Order records instead of one when an Opportunity is marked as Closed Won. This could be caused by:
➡️ Trigger recursion
➡️ Duplicate logic in Flows + Apex
➡️ Improper use of static variables
➡️ Automation running multiple times (Flows, PB, Apex, etc.)
To fix this, a developer must trace exactly what code paths are executing and when duplicate logic is triggered.
✅ Why D is Correct (System.debug + Developer Console):
✔ Adding System.debug() statements gives granular, line-by-line visibility of how the trigger is executing.
✔ The Developer Console logs allow devs to trace trigger execution, DML statements, and potential recursion or duplicate logic paths.
✔ You can confirm where the second Order is created, and whether it’s coming from a trigger, flow, or Apex method.
✔ Most efficient and developer-friendly way to pinpoint logic bugs or recursive execution.
❌ Why Other Options Are Incorrect:
A. Disable all flows and re-enable one by one:
➯ This is manual and time-consuming.
➯ Disabling all flows can impact unrelated automation.
➯ Doesn't confirm if issue is caused by flows, triggers, or other automation.
➯ Risky in a shared org or production environment.
B. Run Apex test classes:
➯ Running test classes checks coverage and correctness, but won’t expose runtime duplication issues unless tests are specifically written for this scenario.
➯ Doesn’t provide detailed trace of trigger logic during normal use.
C. Set up debug logging for every Sales Rep:
➯ Impractical and excessive — too many logs.
➯ The issue is with trigger logic, not necessarily user-specific behavior.
➯ Hard to manage and monitor logs for each individual user.
📚 Reference:
🔗 Salesforce Developer Guide – Debugging Apex Code
🔗 Understanding Apex Trigger Recursion
A developer is working with existing functionality that tracks how many times a stage has changed for an Opportunity. When the Opportunity’s stage is changed, a workflow rule is fired to increase the value of a field by one. The developer wrote an after trigger to create a child record when the field changes from 4 to 5. A user changes the stage of an Opportunity and manually sets the count field to 4. The count field updates to 5, but the child record is not created. What is the reason this is happening?
A. Trigger.old does not contain the updated value of the count field.
B. After triggers fire before workflow rules.
C. Trigger.new does not change after a field update.
D. After triggers are not fired after field updates.
Explanation:
To determine why the child record is not created when the Opportunity’s count field updates from 4 to 5, despite an after trigger designed to handle this transition, we need to analyze the interaction between the workflow rule and the trigger in the given scenario. The developer set the count field to 4 manually, and a workflow rule increments it to 5, but the expected trigger behavior does not occur. Let’s evaluate the options based on Salesforce’s order of execution and trigger context.
Scenario Breakdown:
➜ The Opportunity has a field (e.g., Stage_Change_Count__c) tracked by a workflow rule that increments it by 1 when the stage changes.
➜ The developer wrote an after trigger to create a child record when Stage_Change_Count__c changes from 4 to 5.
➜ A user manually sets Stage_Change_Count__c to 4 and changes the stage, triggering the workflow rule to increment it to 5.
➜ The child record is not created, indicating the trigger did not detect the 4-to-5 transition as expected.
Salesforce Order of Execution:
1. Loads the original record.
2. Executes all before triggers.
3. Runs system validation rules, duplicate rules, etc.
4. Saves the record to the database (but not committed yet).
5. Executes all after triggers.
6. Executes assignment rules.
7. Executes auto-response rules.
8. Executes workflow rules (field updates are applied here).
9. If field updates cause changes, the order repeats from step 3 for those changes (up to 5 iterations).
10. Executes escalation rules, processes, and flows.
11. Executes post-commit logic (e.g., email notifications).
Key Insight:
➜ Workflow field updates occur after after triggers, and if they modify a field, the system re-evaluates the record, potentially firing additional triggers or rules.
➜ However, the trigger context (e.g., Trigger.new, Trigger.old) reflects the state at the time of the initial trigger firing, not the post-workflow update, unless the update triggers a new transaction.
Evaluation of Options:
A. Trigger.old does not contain the updated value of the count field.
Trigger.old contains the original field values before the update, while Trigger.new contains the new values after the user’s change but before workflow updates. When the user sets Stage_Change_Count__c to 4, Trigger.old might have the prior value (e.g., 3), and Trigger.new initially has 4. The workflow then updates it to 5, but this update happens after the after trigger fires. The trigger compares Trigger.oldMap.get(oppty.Id).Stage_Change_Count__c (e.g., 3) to Trigger.newMap.get(oppty.Id).Stage_Change_Count__c (e.g., 4), missing the 4-to-5 transition. This is a plausible reason, as the trigger doesn’t see the workflow’s update in its context.
B. After triggers fire before workflow rules.
This is incorrect. Per the order of execution, after triggers fire before workflow rules (step 5 vs. step 8). The workflow’s field update occurs after the after trigger, so the trigger cannot rely on the updated value during its initial execution.
C. Trigger.new does not change after a field update.
Trigger.new reflects the state of the record after the user’s change but before workflow updates. When the workflow updates Stage_Change_Count__c to 5, this change is not reflected in the initial Trigger.new context because the trigger has already fired. However, if the workflow update triggers a re-evaluation (step 9), a new trigger context could be created, but the problem suggests the original trigger instance misses the update. This option is partially true but not the primary reason— the issue is the timing, not immutability.
D. After triggers are not fired after field updates.
After triggers can fire again if a field update from a workflow causes a re-evaluation (up to 5 iterations). However, the initial after trigger fires based on the user’s change (e.g., stage update), and the workflow update to 5 happens afterward. The trigger logic likely checks the transition within the same context, missing the subsequent update. This option is misleading—triggers can fire after field updates, but the original trigger instance doesn’t see the new value.
Correct Answer: A. Trigger.old does not contain the updated value of the count field.
Reason: The issue occurs because the after trigger compares Trigger.oldMap and Trigger.newMap values based on the initial state (e.g., Trigger.oldMap.get(oppty.Id).Stage_Change_Count__c = 3 and Trigger.newMap.get(oppty.Id).Stage_Change_Count__c = 4) when the user sets it to 4. The workflow rule then increments it to 5 after the trigger fires, but this change is not reflected in the original Trigger context. The trigger’s logic (e.g., if (oldCount == 4 && newCount == 5)) fails because it never sees the 5. To fix this, the developer should handle the re-evaluation context or use a recursive check (e.g., static variable) to detect the 4-to-5 change across iterations.
Inferred Trigger Code (Problematic):
trigger OpportunityTrigger on Opportunity (after update) {
for (Opportunity oppty : Trigger.new) {
Integer oldCount = Trigger.oldMap.get(oppty.Id).Stage_Change_Count__c;
Integer newCount = oppty.Stage_Change_Count__c;
if (oldCount == 4 && newCount == 5) {
insert new Child_Object__c(Opportunity__c = oppty.Id);
}
}
}
Fix: Add a static flag or handle the workflow update in a separate trigger context.
Reference: Salesforce Apex Developer Guide - Trigger Context and Order of Execution.
Additional Notes: To resolve, use a static variable (e.g., public static Boolean isFirstRun = true;) to track the first run and re-evaluate in a second iteration, or use a Process Builder/Flow to create the child record after the workflow update. Test with a stage change and manual field update in a sandbox.
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 analyze and diagnose the problem in the Lightning page?
A. Salesforce Lightning Inspector Transactions tab
B. Salesforce Lightning Inspector Actions tab
C. Salesforce Lightning Inspector Event Log tab
D. Salesforce Lightning Inspector Storage tab
Explanation:
The Lightning page has many components that cache reference data. Users are reporting that the page does not always show the most up-to-date data. This suggests a potential issue with how data is being stored and retrieved from cache — specifically client-side storage like Lightning Data Service, @wire, or localStorage/sessionStorage.
To diagnose caching issues, you need to inspect how and where the component is storing data, and whether it is properly refreshing or invalidating outdated cache.
✅ Why D is Correct (Salesforce Lightning Inspector – Storage tab):
➜ The Storage tab of the Salesforce Lightning Inspector lets you view and debug local storage, including:
✔ Lightning Data Service cache
✔ LocalStorage
✔ SessionStorage
✔ IndexedDB
➜ It shows whether components are reading stale data from cache instead of refreshing from the server.
➜ Perfect for investigating why updated reference data isn’t being shown on the page.
❌ Why Other Options Are Incorrect:
A. Transactions tab
➲ Shows framework lifecycle events like rerenders, rehydration, and rendering performance.
➲ Useful for analyzing performance, but not for debugging stale data or cache.
B. Actions tab
➲ Displays server-side actions and their parameters/responses.
➲ Helps in analyzing Apex controller calls, but doesn’t reflect client-side cache behavior.
C. Event Log tab
➲ Logs Lightning framework events, including component-level communication.
➲ Useful for event-driven architecture debugging, but not relevant for storage/cache problems.
📚 Reference:
🔗 Salesforce Lightning Inspector Documentation
🔗 Diagnose Lightning Component Performance
| Salesforce-Platform-Developer-II Exam Questions - Home | Previous |
| Page 5 out of 41 Pages |