Update: All the discussion on this post led me to create a much better solution called Send Email that ships with the Exchange connector. I HIGHLY recommend checking that out as a better alternative to this.
http://blogs.technet.com/b/servicemanager/archive/2011/01/07/exchange-connector-released.aspx
==================
In the MP XML below I've created a notification subscription that will send a notification to the affected user whenever the action log has an analyst comment added to it.
<ManagementPack ContentReadable="true" SchemaVersion="1.1" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<Manifest>
<Identity>
<ID>ActionLogAddRelationshipSubscription</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>Action Log Add Relationship Subscription</Name>
<References>
<Reference Alias="Console">
<ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>
<Version>7.0.5826.859</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="NotificationsLibrary">
<ID>System.Notifications.Library</ID>
<Version>7.0.5826.0</Version>
<Reference Alias="WorkItem">
<ID>System.WorkItem.Library</ID>
<Reference Alias="ServiceManager.IncidentLibrary">
<ID>ServiceManager.IncidentManagement.Library</ID>
<Reference Alias="System">
<ID>System.Library</ID>
<Reference Alias="IncidentLibrary">
<ID>System.WorkItem.Incident.Library</ID>
<Reference Alias="Subscriptions">
<ID>Microsoft.SystemCenter.Subscriptions</ID>
<Reference Alias="Administration">
<ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
</References>
</Manifest>
<Categories>
<Category ID="Category.ActionLogAddRelationshipSubscriptions.ManagementPack" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack">
<ManagementPackName>ActionLogAddRelationshipSubscription</ManagementPackName>
<ManagementPackVersion>7.0.5826.0</ManagementPackVersion>
</Category>
<Category ID="Category.ActionLogAddRelationshipSubscriptionRule" Target="ActionLogAddRelationshipSubscriptionRule" Value="Administration!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions" />
<Category ID="ActionLogAddRelationshipAffectedUserNotificationTemplate.Category" Target="ActionLogAddRelationshipAffectedUserNotificationTemplate" Value="Administration!ServiceManager.Console.NotificationManagement.NotificationTemplates.Enumeration" />
</Categories>
<Monitoring>
<Rules>
<Rule ID="ActionLogAddRelationshipSubscriptionRule" Enabled="true" Target="ServiceManager.IncidentLibrary!System.WorkItem.Incident.WorkflowTarget" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>System</Category>
<DataSources>
<DataSource ID="DS" TypeID="Subscriptions!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
<Subscription>
<RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicketHasAnalystComment']$" SourceType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicket']$" TargetType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicket.AnalystCommentLog']$">
<AddRelationship />
</RelationshipSubscription>
<PollingIntervalInSeconds>30</PollingIntervalInSeconds>
<BatchSize>100</BatchSize>
</Subscription>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="WA" TypeID="Subscriptions!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
<EnableBatchProcessing>false</EnableBatchProcessing>
<WindowsWorkflowConfiguration>
<AssemblyName>Microsoft.EnterpriseManagement.WorkflowFoundation</AssemblyName>
<WorkflowTypeName>Microsoft.EnterpriseManagement.WorkflowFoundation.ConfigurationWorkflow</WorkflowTypeName>
<WorkflowParameters>
<WorkflowParameter Name="InstanceId" Type="guid">$Data/BaseManagedEntityId$</WorkflowParameter>
<WorkflowArrayParameter Name="UserRelationshipIdList" Type="guid">
<Item>$MPElement[Name='WorkItem!System.WorkItemAffectedUser']$</Item>
</WorkflowArrayParameter>
<WorkflowArrayParameter Name="NotificationTemplateIdList" Type="guid">
<Item>$MPElement[Name='ActionLogAddRelationshipAffectedUserNotificationTemplate']$</Item>
</WorkflowParameters>
<RetryExceptions />
<RetryDelaySeconds>60</RetryDelaySeconds>
<MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
</WindowsWorkflowConfiguration>
</WriteAction>
</WriteActions>
</Rule>
</Rules>
</Monitoring>
<Templates>
<ObjectTemplate ID="ActionLogAddRelationshipAffectedUserNotificationTemplate" TypeID="NotificationsLibrary!System.Notification.Template.SMTP">
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template.SMTP']/Subject$"><1033>Action log entry added to $Context/Property[Type='WorkItem!System.WorkItem']/Id$ </1033><2057>Incident ID: [$Context/Property[Type='WorkItem!System.WorkItem']/Id$] has been updated by the analyst</2057></Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template.SMTP']/Priority$">2</Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template.SMTP']/IsBodyHtml$">True</Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template']/Content$">
<1033>
Details:
Title: $Context/Property[Type='WorkItem!System.WorkItem']/Title$
Description: $Context/Property[Type='WorkItem!System.WorkItem']/Description$
Created By: $Context/Path[Relationship='WorkItem!System.WorkItemCreatedByUser' TypeConstraint='System!System.User']$?$DisplayName$
</1033><2057>Incident Title: $Context/Property[Type='WorkItem!System.WorkItem']/Title$ &lt;br/&gt;
Assigned To: $Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' TypeConstraint='System!System.User']$?$DisplayName$?&lt;br/&gt;
Updated action log entry: &lt;br/&gt;
&lt;table&gt;
&lt;Group&gt;
&lt;tr&gt;
&lt;td&gt;
$Context/Path[Relationship='WorkItem!System.WorkItem.TroubleTicketHasAnalystComment' TypeConstraint='WorkItem!System.WorkItem.CommentLog']/Property[Type='WorkItem!System.WorkItem.CommentLog']/Comment$
&lt;/td&gt;
&lt;/tr&gt;
&lt;/Group&gt;
&lt;/table&gt;</2057></Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template']/Encoding$">utf-8</Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template']/SeedClass$">System.WorkItem.Incident</Property>
<Property Path="$Context/Property[Type='NotificationsLibrary!System.Notification.Template']/Protocol$">SMTP</Property>
</ObjectTemplate>
</Templates>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="ActionLogAddRelationshipSubscription">
</DisplayString>
<DisplayString ElementID="ActionLogAddRelationshipSubscriptionRule">
<Name>Action log entry added to action log</Name>
<DisplayString ElementID="ActionLogAddRelationshipAffectedUserNotificationTemplate">
<Name>Notify affected user that action log entry has been added to action log</Name>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
Creating relationship subscriptions is actually pretty easy. You just need to follow the pattern above and replace certain configurable parameters with the correct values. I'll explain those here for reference:
First is the Target of the Rule. Unless you know what you are doing, you should probably stick to using a workflow target from among the out of the box list of workflow targets:
Workflow Target Class ID
Workflow Target Class MP
System.WorkItem.Activity.InternalWorkflowTarget
ServiceManager.ActivityManagement.Library
System.WorkItem.Activity.WorkflowTarget
System.WorkItem.ChangeRequest.WorkflowTarget
ServiceManager.ChangeManagement.Library
System.WorkItem.Incident.WorkflowTarget
ServiceManager.IncidentManagement.Library
System.WorkItem.Problem.WorkflowTarget
System.WorkItem.Problem.Library
You can get more information on Workflow target from this blog post if you need to do something beyond the above.
Next is to define which RelationshipType you are subscribing to. You can get a list of the relationship type IDs from the database by using the queries provided in this blog post. Each Relationship Type has a Source Class and a Target Class. You can get those from the same blog post using SQL queries.
Next up is to indicate which Related Users you are going to notify. Do this by indicating the relationship type which points from the class that you are notifying about (in this case the Incident class) to a System.Domain.User class. You can get the Relationship Types again using the database query post above.
Last is to indicate which Notification Template you will use. In this case I am using a notification template defined in the same MP.
One last note. You'll see that in this notification template I did something a little fancy. I inserted a insert tag for the Action Log (i.e. TroubleTicketHasAnalystComment relationship type). The relationship between an incident and action log comments is 1:many. So – how do you show that in a notification template? Ideally you would show a list of the action log entries. The same could be true for related configuration items, related work items, etc. In other words anything where there are many items related to the item you are notifying about.
To deal with this we have created a special <Group> tag that can be used in the notification template. When you surround the Insert tag with the Group tag we will iterate through everything in the Group tag and repeat it for each related object.
This is what the Group tag looks like in the notification template properties dialog:
=================================
Incident Title: $Context/Property[Type='WorkItem!System.WorkItem']/Title$ <br/>
Assigned To: $Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' TypeConstraint='System!System.User']$?$DisplayName$?<br/>
Updated action log entry: <br/>
<table>
<Group>
<tr>
<td>
</td>
</tr>
</Group>
</table>
And this is what it looks like when sent in HTML.
Incident Title: Test Subject Assigned To: Aaron JamesUpdated action log entry:
test6
test7
test3
test2
test4
test5
testing
Note: per this forum thread we had there is a bug in SCSM 2010 which displays the objects in essentially random order. This has been fixed for SP1.
Hi, I would like to ask the same question as Jay. After removing <Group> tag, all comments from Activity log (from particualar Analyst or End-user) still appears under email notification. SCSM SP1.
Hi Travis,
is there a way to solve this problem using the built-in functionality SCSM 2012? Testing SCSM2012RC we did not find this feature.
Thank you.
Just wanted to check in. Under SCSM 2012 removing the group tag still iterates through all the user comments. Is there a way to change that so only the most recent comment is included? I understand that is supposed to the behavior when you remove the group tags but it's still showing all of them.
Thanks for this great blog.
I need to notify the primary owner when end user add comment from portal, i used the above MP and made some modifications in relationship type, source class and target class but it's not working.
Appreciate your help in this issue.
Thanks in advance.
Hello! This MP has helped me out so much, and your comments have been great.
However, I'm suddenly seeing that Analyst Comments marked as Private are not being sent in the notification! Every e-mail reply I send as the Assigned Analyst is automatically getting flagged as Private and when the Affected User receives the notification the section of the e-mail where the comment(s) should be is blank.
Also, the replies are marked as Private with a square tick mark, and not a check mark. If I uncheck my comments and resend an e-mail reply, the unchecked comments will appear in the e-mail correctly, but the latest reply is again automatically marked private and does not get sent out.
Is there a way to stop these replies from being marked as private in the first place? It seems they are inheriting this from somewhere, but I can't figure out where. Also, I thought it would send out the analyst comments, private or not?
Thanks for your help!
After much frustrated trial and error, I have discovered that it is the <Group> tags breaking this. If I remove them, the comments come in fine, but ugly and and out of date. If I re-add them, they do not show up at all, unless they are not marked as Private.
I am using these <Group> tags in another notification and they work perfectly. I have copied and pasted the HTML code from above--am I missing something?
Im trying to modify this for a Service Request. Any tips?