You need to sign in to do that
Don't have an account?
HARSHIL U PARIKH
Trigger is not getting fired. It fires only when I individually update the record.
Hello Developers,
I have a trigger on object called Approval__C which creats an event record when Approval_Status__C is Approved.
Trigger is not automatically getting fired when approver approves the record but when I update the 'Approved' record manually then trigger gets fired. How do I make this trigger fire automatically when Approval_Status__c is Approved.
Trigger:
I have a trigger on object called Approval__C which creats an event record when Approval_Status__C is Approved.
Trigger is not automatically getting fired when approver approves the record but when I update the 'Approved' record manually then trigger gets fired. How do I make this trigger fire automatically when Approval_Status__c is Approved.
Trigger:
Trigger CreatingAnEvent on Approval__c(After update){ Event evt = new Event(); If(Trigger.isUpdate || Trigger.isUndelete) { For(Approval__c AP: Trigger.old) { if(AP.Approval_Status__c != 'Approved') { // Nothing } else { evt.ACA_Location__C = AP.Location__c; evt.StartDateTime = AP.Start_Time__c; evt.EndDateTime = AP.End_Time__c; evt.Type = AP.Type__c; evt.Description = AP.Situation__C; evt.Subject = AP.Subject__C; evt.OwnerID = String.valueOf(AP.OwnerId); // "Owner" is an assign to // evt.What = AP.RecordID; // "what" is a relate to evt.DurationInMinutes = 0; insert evt; } } } }Thank you for the help!
Try changed "Trigger.old" to "Trigger.new". Also, you'll want to move the "insert evt" statement outside of your for loop and bulkify it, in order to avoid Salesforce's governor limits.
Doing both items I suggested, you should get something similar to: