You need to sign in to do that
Don't have an account?
HARSHIL U PARIKH
I need to stop this trigger firing twice. I implemented that extra RecursionBlocker method but it is still firing twice.
Apex Class:
But when I update the record again, then new event is created which is needed to be stop.
Thak You for the help!
public class RecursionBlocker{ public static Boolean flag = true; }Trigger: I am creating an event record once the record is approved.
Trigger CreatingAnEvent on Approval_Requests__c(After update){ If(RecursionBlocker.Flag = true){ RecursionBlocker.Flag = false; Event evt = New Event(); If(Trigger.isUpdate) { For(Approval_Requests__c AR: Trigger.New) { If(AR.Approval_Status__c == 'Approved') // Then Create an event record. { evt.StartDateTime = AR.Start_Date_Time__c; evt.ACA_Location__c = AR.ACA_Location__C; evt.Type = AR.Type__C; evt.Description = AR.Situation__C; evt.Subject = AR.Subject__C; evt.OwnerID = String.valueOf(AR.OwnerId); // "Owner" is an assign to evt.Whatid = AR.id; // "what" is a relate to evt.DurationInMinutes = 0; evt.Automatically_Created_Event__c = TRUE; evt.Approved__C = TRUE; evt.Other_Location__C = AR.Other_Location__C; evt.Organization__C = AR.Account__C; evt.whoid = AR.Contact__c; // Who is Name field label on an Event and it's looking up to // either Lead or Contact. For our purpose of creation, we are looking up // to Contact. Id to Id match. insert Evt; } else{ // Do Nothing } } } } }Now, once the record gets approved then an event record gets created -- which is fine!
But when I update the record again, then new event is created which is needed to be stop.
Thak You for the help!
Try to update your code like below
Let us know if this will help you
All Answers
Try to update your code like below
Let us know if this will help you