Troubleshooting email and chatter notifications in deployment manual task

When working with manual tasks in deployments, you can set up the "Task Owner" and the "Notify Task Owner" fields. The purpose of these fields is to send a notification (email, chatter, or both) to the user in the Task Owner field when the deployment reaches that deployment step.

If the notification is not sent via email or the chatter post is not created, you can perform this basic troubleshooting.

1. Make sure there is a user in the Task Owner field. 
Expand the deployment step to see if the Task Owner field is populated with a user. You can also click on the eye icon in the step and check the dataJson field. That field should contain a parameter like Task_Owner":"XXXXXXXXXXXXXXX" where XXXXXXXXXXXXXXX is the record id of the user that will be notified.

2. Make sure that Feed Tracking is enabled for the Deployment object.
The chatter post will be posted in the feed in the deployment record, therefore Feed Tracking must be enabled for this object.
You can do this from Setup | Feed Tracking and search for the Deployment object. There is no need to select any fields. Just enable the feed tracking for the Deployment object.

3. Make sure the user selected in the Task Owner field can send email from Apex and notifications in chatter.
You can do this by sending an email and a chatter post from the apex anonymous window in the developer console. You should be logged with the task owner selected in the deployment step. 
Open the developer console, from the Debug menu, Open Execute Anonymous Window. Enter the code below and click Execute. 
Make sure you have modified the bold text in the code with the right data.


Email from apex anonymous:

Messaging.Singleemailmessage mail = new Messaging.Singleemailmessage();
mail.setToAddresses(new String[] {'email@companyDomain.com'});
mail.setReplyTo('noreply@noreply.com');
mail.setSenderDisplayName('displayName');
mail.setSubject('This is the subject');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('This is the body');
system.debug('@@@@ sendEmail - mail : ' + mail);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });



Chatter post with @mention from apex anonymous:

ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
 
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
 
mentionSegmentInput.id = 'userRecordId';
messageBodyInput.messageSegments.add(mentionSegmentInput);
 
textSegmentInput.text = ' This is the content of the post';
messageBodyInput.messageSegments.add(textSegmentInput);
 
feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
feedItemInput.subjectId = 'deploymentRecordId';
 
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(),feedItemInput);

How did we do?