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 100 discussion

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

A developer writes the following Apex trigger so that when a Case is closed, a single Survey record is created for that Case. The issue is that multiple Survey_c records are being created per Case. trigger CaseTrigger on Case (after insert, after update){ List<Survey_c> createSurveys = new List<Survey_c>(); for (Case c : trigger.new){ if (c.IsClosed && (trigger.isInsert II trigger.isUpdate && trigger.oldMap.get(c.Id).IsClosed == false)){ createSurveys.add(new Survey_c(Case_c = c.Id)); } } insert createSurveys; }
What could be the cause of this issue?

  • A. A user is creating the record as Closed
  • B. A workflow rule is firing with a Create Task action
  • C. A workflow rule is firing with a Field Update action
  • D. A user is editing the record multiple times
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Sri_Vathsa
Highly Voted 2 years, 11 months ago
Answer is C. As the workflow field update, makes the trigger to run again, and in the same transaction instance, so trigger creates second record.
upvoted 7 times
...
Liquad
Highly Voted 3 years, 1 month ago
C. When a workflow's field update triggers a after update event. The Trigger.Old is still not "Closed". So it will insert a second record.
upvoted 5 times
...
Avinash_14
Most Recent 1 month ago
C sounds more suitable. While this could lead to the trigger firing multiple times, it wouldn’t typically cause multiple Survey__c records unless the Case is reopened and closed again. However, the fact that the issue is consistent points more toward a system process, like a Field Update, than manual user behavior.
upvoted 1 times
...
tester1987
10 months, 1 week ago
lol how do we know we have a workflow rule in the system or user is editing the record multiple times. This is shitty question
upvoted 1 times
...
lorenac2
1 year, 10 months ago
Selected Answer: C
Reference: https://architect.salesforce.com/1/asset/immutable/s/2d349e8/assets/images/Salesforce-Order-Of-Execution-Diagram.png
upvoted 1 times
...
sf2022
1 year, 11 months ago
Selected Answer: C
C is correct answer
upvoted 1 times
...
Adarsh168
3 years, 8 months ago
It is not option D. The trigger fires only when it is case is changed from not closed to closed.
upvoted 2 times
rodmfpwc
3 years, 7 months ago
Adarsh168 The trigger fires when the case is changed to 'Closed' but it also fires every time a Case is inserted regardless it is 'Closed' or not. So the trigger is firing more times than expected.
upvoted 2 times
sf2022
1 year, 11 months ago
Trigger is fire multiple-time but only insert Survey_c when Closed, so D is wrong, C is correct
upvoted 1 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 ...