You need to sign in to do that
Don't have an account?

Email Triggers, Obey Database.Dmloptions.Emailheader?
Hi, I'm using Triggers to send out emails on "AfterUpdate", however I'd like the trigger to obey the DML options:
dml.EmailHeader.triggerUserEmail dml.EmailHeader.triggerOtherEmail dml.EmailHeader.triggerAutoResponseEmail
I figured it'd be as easy as an if statement making sure those variables are true, however I can't seem to find a way to read these variables, only set them. Is there any way to do this?
My first thought was to try the below, however it returned null:
Database.DMLOptions dml = new Database.DMLOptions(); System.debug(Logginglevel.info,dml.EmailHeader.triggerUserEmail);
Then for kicks, I tried:
System.debug(Logginglevel.info,Database.DMLOptions.EmailHeader);
That didn't work either.
Any pointers? Is this possible?
Thanks in advance!,
Daniel
See the sample code below :
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail= true;
Did this answer your question? if so, please mark it solved.
The link below explains that SObjects have a getOptions() method. Query that to see what options have been set for the object.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm
To actually set options from within the trigger takes a bit of smoke and mirrors. That is explained here:
https://help.salesforce.com/apex/HTViewSolution?id=000176854&language=en_US
Hope this saves some ppl time in the future.