nerdexam
Salesforce

PDII · Question #81

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…

The correct answer is C. A workflow rule is firing with a Field Update action. See the full explanation below for the reasoning.

Question

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?

Options

  • AA user is creating the record as Closed
  • BA workflow rule is firing with a Create Task action
  • CA workflow rule is firing with a Field Update action
  • DA user is editing the record multiple times

How the community answered

(36 responses)
  • A
    6% (2)
  • B
    3% (1)
  • C
    78% (28)
  • D
    14% (5)

Community Discussion

No community discussion yet for this question.

Full PDII Practice