AI OnAI Off
In the absence of any solutions or exaplantion of the behaviour Ive seen Ive decided to programatically create the Notifications.
So first I create the CommentBlock with code like:
_contentRepository.Save(contentBlock, SaveAction.RequestApproval, AccessLevel.NoAccess);
Then I generate my NotificationMessage and Ive 'hijacked' the Approval sequence Channel which is epi-approval and code as is below. It works but fingers crossed that the json for Content does not change in future releases of Episerver:
var dateTimeCreated = DateTime.UtcNow.ToString("o", CultureInfo.CreateSpecificCulture("en-GB")); //2019-11-04T10:40:28.9240851Z
//Note: The json Content property here was copied from the [tblNotificationMessage] db table entry for a Comment block added
// using the CMS editor interface to a folder with an Approval sequence applied to it.
notifier.PostNotificationAsync(new NotificationMessage()
{
ChannelName = "epi-approval",
Content = "{\"status\":7,\"contentLink\":\"" + commentContentLinkId + "\",\"resourceKey\":\"awaitingapproval\",\"comment\":null,\"stepNumber\":1,\"totalSteps\":1,\"created\":\"" + dateTimeCreated + "\"}",
Recipients = recipients,
Sender = sender,
TypeName = "Approval"
});
Using: EPiServer.CMS version=11.12.0
Programatically creating a Block in sub-folder whose parent has an Approval Sequence does not generate the Notification emails, is this a bug?
This works: Manually adding Block via the CMS back-end in blocks folder with inherited Approval Sequence. I investiagted what was happening in the database and this is what occurs when the Block is created in the CMS:
This does not create the Notifications: Programmatically creating a Block and adding to folder with inherited Approval Sequence is as below. The problem here is that the Notification email is never generated in the [tblNotificationMessage] table:
So when I programatically add the Block that is in a Approval Sequence NO notifications are generted = no emails sent to the relevant modertators.
Is this a bug?
Is there any way to tell Episerver to create the Notifications for the Approval Sequence other than programatically using the INotifier interface?
If I have to us the INotifier interface is it possible to use the epi-approval Channel and Approval type like in code below: