Hi I am building custom web to case functionality,

Here case getting created from Lighting component which is hosted in a force.com site.

As soon as the case submitted from the site, case is created in salesforce.

Here is the code

Case c = new Case ();
c.SuppliedEmail = '[email protected]';
c.ContactId ='0030v00000Mn1AhAAJ';
c.Origin = 'US/CAN';
c.RecordTypeId ='012o0000000ql6MAAQ';
c.Subject = 'Test';
c.Description = 'Some description';

Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerAutoResponseEmail = true;


When I execute this code in Internal User context the case created in salesforce and Auto response rule files and Acknowledgement email has been sent to the Contact's Email

The problem: When I execute the same code with Site User Context in the sense that same code is being called from lightning component which is hosted in force.com site, case is created in salesforce, but it will not fire the AutoResponse rule.

Below are things I verified in the org,

  1. Permission for accessing the object
  2. Org wide email address is set to all profiles
  3. Give the Send Email permission to site guest user profile.
  4. Used Email template is placed in public folder.

Apart from is there any thing I have to setup ?

I also been to this https://help.salesforce.com/articleView?id=creating_auto-response_rules.htm&type=5 documentation

Can somebody tell me is there any alternative to trigger auto response when case created from Site Guest User?

Thank you,

  • in debug log, do you see the auto-response rules run?
    – cropredy
    Commented Oct 26, 2019 at 13:59
  • In debug log for Internal user context it shows the Autoresponse rule, But for Site guest user it will not
    – Sudarshan
    Commented Oct 26, 2019 at 14:11
  • so, if you had only a trivial auto-response rule where if (true=true), the email is not sent? That is, there's nothing in the rules that depend on the running user context?
    – cropredy
    Commented Oct 26, 2019 at 18:40
  • what if(true=true) I didn't get it
    – Sudarshan
    Commented Oct 27, 2019 at 9:55

2 Answers 2


I have resolved this issue,

The take away, whenever an after insert trigger try to update the same case / lead, with out adding below statement. Database.DMLOptions and EmailHeader.triggerAutoResponseEmail = true, will ends in not firing the auto response rule.

So we have to manually add the EmailHeader.triggerAutoResponseEmail to true one more time while updating the same record in after insert.


You can take out the Update logic to some asynchronous action.

  • 1
    so you need to UPDATE (using the header) the newly-CREATED record? Using the header on the insert is not sufficient?
    – cropredy
    Commented Oct 27, 2019 at 14:34
  • Updated same record on after insert trigger with email header set to TRUE, but still auto response email not sent. I can although see on debug logs there is a entry by RESPONSE_NOTIFICATION which mentions the rule that is satisfied, however nothing on email log because the email is never sent.
    – Sagnik
    Commented Nov 8, 2022 at 15:24

You say the email template is contained in a public folder. I seriously doubt the force.com site users have access to this folder. But presumably the trigger should run in the context of the case owner, which I'd hope is not the force.com site user. Are you creating any kind of assignment rule?

I strongly suspect what's at the root of your issue here is that you're not using the declarative functionalities built into Service Cloud for case creation and assignment for cases created from your force.com site. I see you were using the Community Tag in your post which I've edited and change to force.com sites. In either case, you really shouldn't need to be inserting these using a trigger at all. Is there a reason you're not using Web to Case? That would automatically insert these cases for you from either a site or community.

You don't need to give email permissions to your user to send them an auto-response email. They're not the ones who are sending the email, the system is sending it to them. You've also tagged your post for Salesforce1-app. Is there a particular reason for that? What does it have to do with your question? I recommend you change your site to use the web to case form either within a component if you wish or embedded in a standard visualforce page that sites uses. You'll find the documentation here.

  • Thank you for your response, I am not using standard web to case because a lot of business use cases and other customization. So I have created a custom lightning component and embedded in public community page. So I am calling a method to save the case data captured in the form.
    – Sudarshan
    Commented Oct 26, 2019 at 14:07
  • Salesforce1-app is typo thank you for correcting. And its not standard quick action from the community.
    – Sudarshan
    Commented Oct 26, 2019 at 14:10
  • If that's the case, you may want to learn more about how to utilize web to case. You can have multiple web to case forms (and fields) as appropriate to your needs.
    – crmprogdev
    Commented Oct 26, 2019 at 14:10
  • Do you have any reference ? Can you please share it
    – Sudarshan
    Commented Oct 26, 2019 at 14:12
  • So when you create Community, A site profile is created with Guest User Right ? So in that case with default case created by is site guest owner
    – Sudarshan
    Commented Oct 26, 2019 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .