Let's consider the below example, I have created a case from visualforce page. When certain criteria met, then I need to change the ownership to the queue and need to send an email alert to the queue members.
Normally queue email won't go to the queue member, when you update the ownership to queue through apex. For this, Use Database.DmlOption and update the ownership by checking emailHeader.triggerUserEmail check box.
Normally queue email won't go to the queue member, when you update the ownership to queue through apex. For this, Use Database.DmlOption and update the ownership by checking emailHeader.triggerUserEmail check box.
- Case newCase = new Case();
- newCase.Status = 'New';
- insert newCase;
- Group grp = [select Id from Group where Name='Case Student Queue' and Type = 'Queue'];
- newCase.OwnerId = grp.Id;
- Database.DmlOptions options = new Database.DmlOptions();
- options.emailHeader.triggerUserEmail = true;
- Database.update(newCase, options);
Reference:
No comments:
Post a Comment