# Certified-Platform-Developer-II — Question 604

**Type:** multiple_choice
**Topics:** topic_1

## 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?

## Correct Answer

_See scenario._

## Explanation

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.

**Reference:** examtopics_top_comment

---
Source: https://hiexam.net/q/salesforce/Certified-Platform-Developer-II/604  
Practice (tracked): https://hiexam.net/study/Certified-Platform-Developer-II/practice