You need to sign in to do that
Don't have an account?
Insert vs Update Trigger
I have a trigger that needs to fire on before insert, after insert, before update and after update conditions -
- Each invokes a different class method.
- The before triggers (insert and update) fire on the affected record(s)
- The after triggers (insert and update) fire on record(s) of a different object
There is also workflows that perform field updates. But only want the update triggers to fire for existing records.
The solutions I've seen (thus far) would work for a "before insert" vs "before update" condition, and similarly work for an "after insert" vs "after update" condition.
How do I prevent the before update and after update triggers from firing on an insert record?
Keep in mind, if the before update trigger (correctly) fires, I DO want the after update trigger to also fire.
Thanks for any strategies / guidance.
- Each invokes a different class method.
- The before triggers (insert and update) fire on the affected record(s)
- The after triggers (insert and update) fire on record(s) of a different object
There is also workflows that perform field updates. But only want the update triggers to fire for existing records.
The solutions I've seen (thus far) would work for a "before insert" vs "before update" condition, and similarly work for an "after insert" vs "after update" condition.
How do I prevent the before update and after update triggers from firing on an insert record?
Keep in mind, if the before update trigger (correctly) fires, I DO want the after update trigger to also fire.
Thanks for any strategies / guidance.
All Answers
Hi,
If you want workflow rule not to fire while inserting the record. Then put below condition in rule Criteria.
NOT(ISNEW)
Also, In trigger update conditions never fire while inserting the record.
Can you please share your trigger? So that I can analyse and guide you accordingly.
Thanks
Deepak
This needs to be bulletproof down the line when the SA (or future SA) adds new workflows.
I ~may~ have found a solution (more testing needed). In the "after" section, I'm going to insert a check to see if the CreatedDate and LastModifiedDate fields are the same - if they are, it's an insert, and the update routine should be ignored (or perhaps I need to allow for a 1 second differential? Will test this).
As requested, here's my trigger structure: Think I might be onto something by checking the createdDate vs lastModifiedDate during the update routine? Other strategies?
Seems a bit of a cludge though - if anyone has a better, "more sanctioned" solution, please reply :)
Thanks,
Pete