0

When running this code as a community user to create a case the Auto-Response email rule is being triggered

Case myCase = new Case(
            AccountId = company.Id,
            ContactId = testCommunityContact.Id,
            OwnerId = QueueId,
            RecordTypeId = GE_CASE_RECORD_ID,
            Subject = 'Test Subject',
            Description = 'Test Description'
        );
        
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.emailHeader.triggerAutoResponseEmail = false;

Database.insert(myCase, dmlOpts);

Is this expected behaviour for community users? I cannot see any mention of this behaviour - https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_EmailHeader.htm

I did find this current known issue - https://success.salesforce.com/issues_view?id=a1p3A000000Fmk0QAC But that is the opposite of what we are experiencing...

10
  • As per SF doc, if triggerAutoResponseEmail is set to false, then the email is sent to the address specified in SuppliedEmail. Have you checked if the SuppliedEmail in case object is being defaulted or updated by some other process? And, is this happening only for community users?
    – arut
    Jun 24 at 4:41
  • Correct this ONLY happens for community users And added System.debug(JSON.serializePretty([SELECT CaseNumber, SuppliedEmail FROM Case])); to my test method and SuppliedEmail is blank/null Searched the apex and flows, there is no references about that field, so definitely caused by that field populated.
    – Tony White
    Jun 24 at 6:05
  • While it shows up null value in system.debug statements, have you checked by querying a record that has been created?
    – arut
    Jun 24 at 6:17
  • Yep, confirmed it is null even when viewing the created record.
    – Tony White
    Jun 25 at 11:19
  • Could it be possible that there are other email notifications configured in the org? For testing, can you deactivate all the case auto response rules (there by making the DML Options pointless)? and, check if emails are still getting generated?
    – arut
    Jun 26 at 5:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.