You need to sign in to do that
Don't have an account?
Varun Chaddha
Email Notifications are enabeld for user in My Setitngs:
Global Settings for Allow User to control Notifications also Enabled:
Based on these settings the Email Notification should have received by the User. And the OwnerId passed in the code is NOT the Logged In User, so the code should ahve triggerred email notifications. Please correct me if I'm wrong, but it looks like something is broken here. The code sends out Email Notifications ONLY when I've disabled "Enable User Control Over Task Assignment Notifications" globally for all users.
Task Email Notifications via APEX not working, could be a Bug in platform?
Database.DMLOptions dm = new Database.DMLOptions(); dm.EmailHeader.triggerUserEmail = true; Task t = new Task(Subject='Test Task', ActivityDate=date.today(), OwnerId='00590000000wND2'); database.insert(new Task[]{t}, dm);
Email Notifications are enabeld for user in My Setitngs:
Global Settings for Allow User to control Notifications also Enabled:
Based on these settings the Email Notification should have received by the User. And the OwnerId passed in the code is NOT the Logged In User, so the code should ahve triggerred email notifications. Please correct me if I'm wrong, but it looks like something is broken here. The code sends out Email Notifications ONLY when I've disabled "Enable User Control Over Task Assignment Notifications" globally for all users.
To further narrowdown the issue, I was able to confirm that, this issue is there when we create Tasks from Batch APEX, and not from normal usual APEX controller class.
To confirm this you can follow following Code Classes/VF Pages to see that issue exist in platform regarding this:
Visualforce Page Code:
APEX Controller Class:
BATCH Apex Class:
Now, we can see that, when I click "Create Task" button, it initiates a normal APEX class function, and in that way I receive Task Assignment Notification.
But when I click "Create Task (batch)" button, it initiates a Batch apex call to the function and that does not send any Task Assignment Notification. I don't see anywhere in the docs that cofnirms this theory, by logic, the notifications should work correctly even from Batch Apex, as it is APEX Api.
I would have a different use than you, but it most likely roots in the same issue.
http://docs.releasenotes.salesforce.com/nl-nl/winter15/release-notes/rn_sales_activities_notifications_task_assignment.htm
It definitely was a bug in platform, but no one recognized it. I could very well reproduce it via code posted in here, but a quick test in Summer '15 Pre-release organization revealed that it has been fixed. I could not reproduce it Summer 15 Org but could reproduce that Batch Apex generated Tasks were not sending Task Notifications. So I'm glad and thus thought of updatign this post here that the issue seems to be resolved in Pre-release org, and I hope it remains fixed with final Summer '15 platform release.
Best
Roger