Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 125 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 125
Topic #: 1
[All Certified Platform Developer II Questions]

A developer has written an After Update trigger on Account. A workflow rule and field update cause the trigger to repeatedly update the Account records.
How should the developer handle the recursive trigger?

  • A. Deactivate the trigger and move the logic into a Process or Flow
  • B. Deactivate the workflow rule to prevent the field update from executing
  • C. Use a static variable to prevent the trigger from executing more than once
  • D. Use a global variable to prevent the trigger from executing more than once
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Sapphire808
1 year, 1 month ago
Selected Answer: C
Deactivating the workflow rule would remove the logic that may still be needed. Moving it to flows and process builders could work but there are other options that would be easier to implement. A global variable is too broad. A static variable will hold the value during the run of all processes that are triggered (during the threaded call) and will maintain its value in the context of this process.
upvoted 1 times
...
Liquad
3 years, 2 months ago
A static variable is static only within the scope of the Apex transaction. It’s not static across the server or the entire organization. The value of a static variable persists within the context of a single transaction and is reset across transaction boundaries. For example, if an Apex DML request causes a trigger to fire multiple times, the static variables persist across these trigger invocations. To store information that is shared across instances of a class, use a static variable. All instances of the same class share a single copy of the static variable. For example, all triggers that a single transaction spawns can communicate with each other by viewing and updating static variables in a related class. A recursive trigger can use the value of a class variable to determine when to exit the recursion.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...