1

I have a public site that allows anonymous users to submit a form, which creates a My_Custom_Object__c record in salesforce. The record is then assigned to a queue in a before trigger.

I'd like to send an email to all queue members informing them of a new record in the queue, but this doesn't appear to be working as expected.

I've tried all the different settings on the queue as per queue case email notifications to all users, but the email is only being sent if I go into the UI, change the owner to the queue, and tick the 'Send Notification Email'.

Is this expected behaviour? Is it possible for the queue to receive an automated email upon record creation? I'm assuming salesforce doesn't see this as an assignment to the queue because the owner of the record isn't changing.

I was hoping to avoid having to use a workflow rule for this.

4

Yes, the default is not to send an email. If you're using a DML statement in your page, you can set the DmlOptions emailHeader. It looks approximately like this:

Database.DmlOptions option = new Database.DmlOptions();
option.emailHeader.triggerUserEmail = true;
Database.insert(theRecord, option);

If your page is using a standard controller, you should be able to use a recursive trigger update to do this:

trigger X on Y (after insert) {
    SObject[] clones = Trigger.new.deepClone(true);
    Database.DmlOptions option = new Database.DmlOptions();
    option.emailHeader.triggerUserEmail = true;
    // assign new owners, then...
    Database.update(clones, option);
}
2
  • Thanks @sfdcfox. I assume this means my assumptions are correct and a queue only receives emails when the owner is changed via the UI?
    – Nick Cook
    Aug 8 '16 at 1:53
  • @NickCook No, it'll receive notifications if you trigger email notifications; the checkbox on the UI is basically the same as the EmailHeader option.
    – sfdcfox
    Aug 8 '16 at 2:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.