function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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).
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.
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.