+ Start a Discussion
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12 

is it possible to inactivate status of a trigger from trigger code itself?

means i wrote a trigger to send a mail .After sending mail for first time the status of that trigger is inactive(fires only onces).
bob_buzzardbob_buzzard
You can't update the trigger metadata - the best that you could do is to update a record in the database or a custom setting and have the trigger check that before it executes.
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
throught coding i want to achieve this ,is it possible?
Maros SitkoMaros Sitko
You want to prevent run that trigger more times during one transaction or for one record. If for transacion you can create class with static variable - when trigger run first time, it will check value if it is true, if yes, code will set value to false end send email. If it is false email will not send. Be carefull with this, becasuse if you want send email for each record, this aprouch does not work with more then 200 record( more bulks).
If you want prevent run trigger more times for one record, move this variable to object (some helper field) and check it as mention upper.