0

We recently put together a small APEX Controller with VF page to act as a Web-to-Case form. It's running on a VF Site, and embedded in an iframe into our main website. This was done to allow users to create a Case and upload files (as ContentDocuments with Links to the Case).

At this point, the Case is being created and the file uploads handled. However, there are no auto-response emails sent. Apparently there is a configuration our admins tweaked to send a "case received" email when a case is created. The standard Web2Case setup triggered these (but of course doesn't allow file uploads).

I think the relevant code is:

Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.AssignmentRuleHeader.useDefaultRule = true;
dmlOpts.EmailHeader.triggerAutoResponseEmail = true;
if (emailIsContact) {
    dmlOpts.EmailHeader.triggerOtherEmail = true;
}
WebCase.setOptions(dmlOpts);
//..
INSERT WebCase;

We're checking if the entered email is on a Contact record, and if so then a) that contact is associated with the case, and b) it's flagged and we set the triggerOtherEmail flag (setting this for emails of non-contacts seems to be a problem).

However, we're not seeing any auto-response emails go out (we've used several test contact of internal users).

1 Answer 1

0

The sobject.setOptions method seems a bit flaky (I've been meaning to ask someone about that). Try using the Database.insert(record, options) method instead:

Database.insert(WebCase, dmlOpts);
2
  • It took a while to get our admin to try out the new code. Unfortunately it's seeming to function the same as before. At this point I really suspect something possibly related to permissions for the anon Sites user.
    – Robert
    Feb 28, 2018 at 3:08
  • @Robert Odd. Time to dig through some debug logs, it sounds like.
    – sfdcfox
    Feb 28, 2018 at 3:14

You must log in to answer this question.

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