- System Center 2012 Service Manager
- Using a related object from the deleted relationship to notify ex-assigned analysts (C# version)
Using a related object from the deleted relationship to notify ex-assigned analysts (C# version)
Engaging data from deleted relationships can be very useful in some cases. For instance, to be aware if someone deletes affected users in the closed cases or replaces attachments etc.
In one of my first posts I described how to send notification to an ex-AssignedTo analyst about a withdrawal. Actually, instead of using the data from the deleted relationship, I created an instance of the new custom relationship using a PowerShell script and used it to send a notification.
Working with a custom relationship can give some advantages but in many cases it would be better just to use related item from the deleted relationship. For instance, if we want to send a message to the ex-assigned analyst in SCSM 2012.
In Microsoft System Center 2012 Service Manager a work item can have the one and only currently assigned analyst and many ex-assigned analysts. And the only way to get the required ex-assigned analyst is to identify the analyst in the moment of the withdrawal.
We can do it using a $Data/RelatedBaseManagedEntityId$ as a workflow parameter.
But if we try to pass this parameter to the default SCSM notification workflow, nothing happens. So we need a custom workflow to send a notification. For this purpose, we can reuse a code presented in my previous posts.
There is one thing to consider about the notification. If we want to use some information about the ex-assigned analyst in the email message (we usually really need that), we cannot use tags like $Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' SeedRole='Source' TypeConstraint='System!System.Domain.User']/Property[Type='System!System.Domain.User']/FirstName$ because the workflow will insert the data from the existing relationship. Of course, we can do it our custom code. In my case I define a keyword [DisplayName] in the notification templates and replace it with the actual display name of the removed user.
I’ve attached an archive where you can find a source code of the solution. To deploy the solution, copy NotifyIfActivitIinProgress.dll to the Service Manager installation folder and import the management pack SCUtils.AssignedToActivity.Workflow.xml into SCSM 2012.