<< Prev Question Next Question >>

Question 2/84

An org has a Process Builder process on Opportunity that sets a custom field,CommissionBaseAmount__c, when an Opportunity is edited and the Opportunity's Amount changes.
A developer recently deployed an Opportunity before update trigger that uses the CommissionBaseAmount__c and complex logic to calculate a value for a custom field CommissionAmount_c, when an Opportunity stage changes to Closed/Won.
Users report that when they change the Opportunity to Closed/Won and also change the Amount during the same save, the C:rr.i;5icnA.T.cur.t c is incorrect.
Which two actions should the developer take to correct this problem? Choose 2 answers

Recent Comments (The most recent comments are at the top.)

Igris - Jun 26, 2025

An org has an existing process, built using Process Builder, on Opportunity that sets a custom field, CcommissionBaseAmount _c, when
an Opportunity is edited and the Opportunity's Amount changes.
A developer recently deployed an Opportunity before update trigger that uses the CommissionBaseAmount__c and complex logic to calculate a
value for a custom field, CommissionAmount c, when an Opportunity stage changes to Closed/Won.
Users report that when they change the Opportunity to Closed/Won and also change the Amount during the same save,
the CommissionAmount __c is incorrect.
Which action should the developer take to correct this problem?

A. Replace the process with a Fast Field Update record-trigger flow.
B. Call the trigger from the process,
C. Call the process from the trigger.

other version of this question .
Ans is A for this question.

Fa3il khayr - Nov 06, 2024

The correct answers are:

C. Use a static Boolean variable in the trigger.
D. Uncheck the recursion checkbox on the process.

Explanation:
When working with both Process Builder and triggers, conflicts can arise due to recursive updates, especially when both are trying to modify related fields within the same transaction. Here’s how each of the correct answers addresses the issue:

C. Use a static Boolean variable in the trigger
Adding a static Boolean variable to the trigger can prevent the trigger from running recursively.
A static variable can be set to true when the trigger runs the first time, and subsequent executions in the same transaction can skip the trigger logic by checking this variable.
This approach helps ensure that the trigger logic is executed only once in a single transaction, preventing issues like unexpected updates to CommissionAmount__c.

D. Uncheck the recursion checkbox on the process
Unchecking the recursion setting in Process Builder prevents the process from re-triggering itself or any dependent logic (like the trigger) when fields it updates are subsequently modified by other processes or triggers in the same transaction.
By turning off recursion, you reduce the risk of infinite loops or unexpected field updates, ensuring that the CommissionBaseAmount__c field is set only once per transaction , reference : https://sf9to5.com/2019/09/17/when-use-recursion-checkbox-process-builder/

Why Not the Other Options?

A. Call the trigger from the process: This is not feasible. Triggers are automatically invoked by data changes; there is no way to directly call a trigger from Process Builder.

B. Call the process from the trigger: Triggers cannot explicitly invoke Process Builder processes. Processes are declarative and triggered by data changes rather than by explicit Apex calls....

Mauricio - Sep 18, 2023

To correct the problem of the incorrect commission amount on the opportunity. According to the Salesforce documentation(1), the order of execution of triggers and processes is as follows:

-Executes all before triggers.
-Executes all after triggers.
-Executes processes and flows launched via Process Builder and Flow Builder.

This means that in your scenario, the trigger runs before the process, and therefore it uses the old value of CommissionBaseAmount__c to calculate the CommissionAmount__c, instead of the updated value that the process sets. To fix this problem, you can take the following two actions:

- Call the process from the trigger. You can use the Process.Plugin class to invoke a process from Apex code2. This way, you can ensure that the process runs before the trigger logic, and that the trigger uses the updated value of CommissionBaseAmount__c.

- Use a static Boolean variable in the trigger. You can use a static Boolean variable to prevent the trigger from running more than once in a single transaction3. This way, you can avoid any unwanted side effects or recursion issues that may occur when calling a process from a trigger.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm...

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

Question List (84q)
2 commentQuestion 1: A developer is writing a Jest for a Lightning web component ...
3 commentQuestion 2: An org has a Process Builder process on Opportunity that set...
Question 3: A developer Is asked to develop a new AppExthange applicatio...
1 commentQuestion 4: A developer sees test failures in the sandbox but not in pro...
1 commentQuestion 5: Universal containers needs to integrate with several externa...
Question 6: Global with sharing class MyRemoter { public String accountN...
1 commentQuestion 7: In an organization that has multi-currency enabled, a develo...
Question 8: A developer is developing a reusable Aura component that wil...
2 commentQuestion 9: Consider the following code snippet: How should &lt;c-order&...
3 commentQuestion 10: What is a benefit of JavaScript remoting over Visualforce Re...
Question 11: An Apex trigger creates a Contract record every time an Oppo...
1 commentQuestion 12: A company uses an external system to manage its custom accou...
Question 13: A company has a native iOS app for placing orders that needs...
Question 14: A developer wrote an Apex method that makes an HTTP callout ...
1 commentQuestion 15: Universal Containers (UC) wants to develop a customer commun...
Question 16: What should a developer use to query all Account fields for ...
Question 17: Account object has a field, Audit_Code__, that is used to sp...
Question 18: A Visualforce page loads slowly due to the large amount of d...
1 commentQuestion 19: As part of a custom interface, a developer team creates vari...
Question 20: Which statement is true regarding savepoints?...
Question 21: Which technique can run custom logic when a Lightning web co...
Question 22: Which use case can be performed only by using asynchronous A...
Question 23: A developer creates a Lightning web component to allow a Con...
2 commentQuestion 24: Consider the following code snippet: How should &lt;c-order&...
Question 25: Users report that a button on a custom Lightning Web Compone...
3 commentQuestion 26: A developer created a Lightning web component that uses a li...
1 commentQuestion 27: A developer is asked to create a Lightning web component tha...
3 commentQuestion 28: A developer is working on a set of custom Aura components th...
Question 29: Universal Containers uses Salesforce to manage its product o...
3 commentQuestion 30: A company manages information about their product offerings ...
Question 31: (Exhibit) The test method above tests an Apex trigger that t...
Question 32: A developer is asked to find a way to store secret data with...
Question 33: A developer created a Lightning web component that allows us...
Question 34: A developer is building a Lightning web component that displ...
Question 35: A business requires that every parent record must have a chi...
Question 36: Consider the following queries. For these queries, assume th...
1 commentQuestion 37: A software company uses a custom object Defect_c, to track d...
Question 38: A developer has requirement to query three fields (id, name,...
Question 39: Refer to the markup below: A Lightning web component display...
Question 40: A developer notices the execution of all the test methods in...
Question 41: (Exhibit) What should be added to the setup, in the location...
Question 42: A developer is writing code that requires making callouts to...
Question 43: (Exhibit) AWC wants the real-time inventory reduction for a ...
Question 44: Which three actions must be completed in a Lightning web com...
4 commentQuestion 45: What are three reasons that a developer should write Jest te...
1 commentQuestion 46: A developer created an Apex class that updates an Account ba...
Question 47: A Visualforce page loads slowly due to the large amount of d...
1 commentQuestion 48: Users upload .csv files in an external system to create acco...
Question 49: A developer has a test class that creates test data before m...
Question 50: Refer to the following code snippets: MyOpportunities.js (Ex...
Question 51: A company uses Opportunism to track sales to their customers...
3 commentQuestion 52: As part of a new integration, a developer is asked to implem...
Question 53: There are user complaints about slow render times of a custo...
Question 54: A company represents their customers as Accounts in Salesfor...
1 commentQuestion 55: Refer to the component code and requirements below: Requirem...
1 commentQuestion 56: Universal Containers implements a private sharing model for ...
Question 57: Refer to the Aura component below: Component markup: (Exhibi...
Question 58: A Page throws an Attempt to dereference a null object error ...
Question 59: Refer to the code snippet below: (Exhibit) When a Lightning ...
2 commentQuestion 60: A developer has working business logic code, but sees the fo...
Question 61: A developer is building a Lightning web component that retri...
Question 62: The following code segment is railed from a Trigger handler ...
1 commentQuestion 63: Consider the Apex class below that defines a RemoteAction us...
Question 64: A company uses Salesforce to sell products to customers. The...
Question 65: The Account object has a field, auais_Code__c, that is used ...
Question 66: Universal Containers (UC) has enabled the translation workbe...
3 commentQuestion 67: A business currently has a process to manually upload orders...
Question 68: After a Platform Event is defined in a Salesforce org, event...
Question 69: (Exhibit) The test method above tests an Apex trigger that t...
1 commentQuestion 70: A developer has created, Lightning web component that uses t...
Question 71: An org records customer order information In a custom object...
1 commentQuestion 72: A developer implemented a custom data table in a Lightning w...
Question 73: (Exhibit) Consider the above trigger intended to assign the ...
Question 74: Given a list of Opportunity records named opportunityList, w...
Question 75: A developer is asked to look into an issue where a scheduled...
Question 76: A large company uses Salesforce across several departments. ...
Question 77: Universal Containers allows customers to log into a Salesfor...
Question 78: Salesforce users consistently receive a "Maximum trigger dep...
Question 79: A developer has a Batch Apex process, Batch_Account_Sales, t...
Question 80: A developer is building a Lightning web component that searc...
1 commentQuestion 81: Refer to the code snippet below: (Exhibit) As part of an Int...
2 commentQuestion 82: Universal Containers needs to integrate with a Heroku servic...
Question 83: Universal Containers wants to use a Customer Community with ...
Question 84: A company wants to incorporate a third-party web service to ...