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
DinDin 

EMailHeader

Hi champs..

 

I am very new to salesforce and apex programming.

 

I am trying to stop an email notification (when case status is set to completed) sent from an apex trigger. I tried setting the EmailHeader.triggerUserEmail = false but it does not seem to work.

 

is there any other way i can stop this notification.

 

Thanks in advance.........


Regards,

Din

Shashikant SharmaShashikant Sharma

try to replicate this example as per yor requirement.

 

Account a = new Account(name='Acme Plumbing');

insert a;

Contact c = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber', accountid=a.id);

insert c;

Database.DMLOptions dlo = new Database.DMLOptions();

dlo.EmailHeader.triggerAutoResponseEmail = true;

Case ca = new Case(subject='Plumbing Problems', contactid=c.id);

database.insert(ca, dlo);

 

Devendra NataniDevendra Natani

trigger Casetrigger on case( before insert)

{

 for (Case c : Trigger.New)

{

if (c.status == 'Completed')

{

Database.DMLOptions dlo = new Database.DMLOptions();  

dlo.EmailHeader.triggerAutoResponseEmail = false;   

c.setOptions(dlo);

}

}

 

}

 

Please let me know if there is any issue.

 

 

DinDin

Hi Dev,

 

Thanks for your reply. I have tried the same solution already which is setting the triggerUserEmail to false but this does not work. I do not know if this is a bug in salesforce?

 

Regards

DinDin

Hi Dev,

 

I have tried these three options but no success

 

triggerUserEmail = false

triggerOtherEmail = false

triggerAutoResponse = false

 

Regards

Devendra NataniDevendra Natani

Can you please send me the code of your trigger?

 

 

 

DinDin

Hi,

 

Thanks for your reply. I am sorry because of the code security I won’t be able to send you the code but I have found another clue in this matter.

 

We are pushing data to salesforce database through SSIS packages and this SSIS package is setting the triggerUserEmail to true when we push data through the salesforce webservices. I have set this triigerUserEmail to false in SSIS package but I won’t be able to test it until our DBA is back.

 

Now my question is........

When we set email header options in service call within SSIS packages do they take priority over EmailHeader options that we specify in apex trigger code?

 

Regards,

 

Din

Devendra NataniDevendra Natani

Hi,

 

Database.DMLOptions dlo = new Database.DMLOptions();  

dlo.EmailHeader.triggerAutoResponseEmail = false;   

c.setOptions(dlo);

 

If the final value of triggerAutoResponseEmail is false then it will work fine otherwise it will not work.

 

 

DinDin

Hi,

 

The final value is false as I am explicitly setting it to false.

 

I think DMLOptions are not working as I am expecting them to work.

 

here is the signature of my trigger

trigger assignCase on Case (before insert, before update)

 

the following post

http://boards.developerforce.com/t5/Apex-Code-Development/using-DMLOptions-in-trigger-not-working/m-p/124461

 

suggested people had issues with assignmentRuleHeader and it worked when they combined it with the triggerUserEmail option. So after following the post I tried setting the assignmentRuleHeader to true but still no success. Now I am thinking to raise this with sales force support what do you think?

 

Regards,

Din

PetiPeti

I have created the trigger, but how do i create a test class to get the nessesary code coverage to push it into production?