Notify Assigned to when the Affected User updates a Service Request from the SSP in SCSM 2012

August 20, 2012 Posted by Stefan Allansson

UPDATE: 05 October 2012 – Please Read

I have done a little change in my code. The original code did send an notification not only if the end user updated the action log, but also if an analyst wrote somethin in the action log from the console.
Thats not what I wanted so I have changed this part:
Old:
TargetType=”$MPElement[Name=’WorkItem!System.WorkItem.CommentLog’]$”
New:
TargetType=”$MPElement[Name=’WorkItem!System.WorkItem.TroubleTicket.UserCommentLog’]$”

—————————————————————————————————————————–

I guess we can say this is a “part 2” blog post about notifications when the end user updates a work item.
The first one that you finds here is for incidents and this is for Service Requests.

For the incident I added an incident template so we could change the status of the incident to “Updated” at same time as we sends the notification to the assigned to user.
For a Service Request I don´t want to change the status, since the status is controlled by the Activities in the Service Request. When the last activity is completed, the service request will also be completed.

I just want to send an e-mail to the assigned to user when the service request is updated by the end user.
For this I have created a similar management pack as in the blog post for incidents that I mentioned above.
I have changed it a little bit so it fits for a service request instead of an incident.
This time I add a notification template instead of a “work item template”, since I just want to send an e-mail.
I also point out the assigned to user as the recipient.

Below you can see the management pack that I have used.
You need to change the GUID (8F842F05-FDE0-31F0-1083-54E111099AA3) for the incident template to the GUID of the template that you want to use.
To get the GUID for your template, login in to your SQL Server and run this query against the ServiceManager database.(put in the display name of your template)

select Objecttemplateid from ObjectTemplate where ObjectTemplateName=’DisplayNameOfYourTemplate’

This query will probably work if you use a built in template but not if you want to use one that you created in the console.
This is because of that the ObjectTemplateName isn´t the same as the display name that your template have in the console. Use this query below instead and compare the result for date and time for when it was created and last changed with the time that you can see in the console for your template.(the time in SQL is showing GMT so the hours can differs from what you see in your console, but the minutes and seconds will be correct.

select * from ObjectTemplate

 

<ManagementPack ContentReadable=”true” SchemaVersion=”2.0″ OriginalSchemaVersion=”1.1″ xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“>
  <Manifest>
    <Identity>
      <ID>LumagateServiceRequestActionLogAddRelationshipSubscription</ID>
      <Version>1.0.0.0</Version>
    </Identity>
    <Name>Lumagate Service Request Action Log Add Relationship Subscription</Name>
    <References>
      <Reference Alias=”Console”>
        <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”NotificationsLibrary”>
        <ID>System.Notifications.Library</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”WorkItem”>
        <ID>System.WorkItem.Library</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”System”>
        <ID>System.Library</ID>
        <Version>7.5.8501.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”Subscriptions”>
        <ID>Microsoft.SystemCenter.Subscriptions</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”Administration”>
        <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”ServiceRequest”>
        <ID>ServiceManager.ServiceRequest.Library</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <Categories>
    <Category ID=”Category.ActionLogAddRelationshipSubscriptions.ManagementPack” Value=”Console!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack”>
      <ManagementPackName>LumagateServiceRequestActionLogAddRelationshipSubscription</ManagementPackName>
      <ManagementPackVersion>7.0.5826.0</ManagementPackVersion>
    </Category>
    <Category ID=”Category.ServiceRequestActionLogAddRelationshipSubscriptionRule” Target=”ServiceRequestActionLogAddRelationshipSubscriptionRule” Value=”Administration!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions” />
  </Categories>
  <Monitoring>
    <Rules>
      <Rule ID=”ServiceRequestActionLogAddRelationshipSubscriptionRule” Enabled=”true” Target=”ServiceRequest!System.WorkItem.ServiceRequest.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.WorkItemHasCommentLog’]$” SourceType=”$MPElement[Name=’WorkItem!System.WorkItem’]$” TargetType=”$MPElement[Name=’WorkItem!System.WorkItem.TroubleTicket.UserCommentLog’]$”>
                <AddRelationship />
              </RelationshipSubscription>
              <PollingIntervalInSeconds>30</PollingIntervalInSeconds>
              <BatchSize>100</BatchSize>
            </Subscription>
          </DataSource>
        </DataSources>
      <WriteActions>
   <WriteAction ID=”WA” TypeID=”Subscriptions!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction”>
   <Subscription>
    <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=”NotificationTemplateIdList” Type=”guid”><Item>8F842F05-FDE0-31F0-1083-54E111099AA3</Item></WorkflowArrayParameter>
    <WorkflowArrayParameter Name=”UserAliasOrRelationships” Type=”string”><Item>$MPElement[Name=’WorkItem!System.WorkItemAssignedToUser’]$</Item></WorkflowArrayParameter>
   </WorkflowParameters>
   <RetryExceptions />
   <RetryDelaySeconds>60</RetryDelaySeconds>
   <MaximumRunningTimeSeconds>1500</MaximumRunningTimeSeconds>
  </WindowsWorkflowConfiguration>
   </Subscription>
   </WriteAction>
  </WriteActions>
  </Rule>
  </Rules>
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID=”ENU” IsDefault=”true”>
      <DisplayStrings>
        <DisplayString ElementID=”LumagateServiceRequestActionLogAddRelationshipSubscription”>
          <Name>Lumagate Service Request Action Log Add Relationship Subscription</Name>
        </DisplayString>
        <DisplayString ElementID=”ServiceRequestActionLogAddRelationshipSubscriptionRule”>
          <Name>Service Request Action log entry added to action log</Name>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>

 
If you for some reson want to add a Service Request template instead of a notification template you have to change the mp a little bit. The part for <WorkflowParameters> is not the same as the mp above.
Here is a mp that works but you need to change the GUID (F473AAAF-8B64-2100-723D-40F7CF62C069) to the GUID for your own template.

<ManagementPack ContentReadable=”true” SchemaVersion=”2.0″ OriginalSchemaVersion=”1.1″ xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“>
  <Manifest>
    <Identity>
      <ID>LumagateServiceRequestActionLogAddRelationshipSubscription</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>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”WorkItem”>
        <ID>System.WorkItem.Library</ID>
        <Version>7.0.5826.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”System”>
        <ID>System.Library</ID>
        <Version>7.0.5826.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”Subscriptions”>
        <ID>Microsoft.SystemCenter.Subscriptions</ID>
        <Version>7.0.5826.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”Administration”>
        <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
        <Version>7.0.5826.859</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias=”ServiceRequest”>
        <ID>ServiceManager.ServiceRequest.Library</ID>
        <Version>7.5.1561.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <Categories>
    <Category ID=”Category.ActionLogAddRelationshipSubscriptions.ManagementPack” Value=”Console!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack”>
      <ManagementPackName>LumagateServiceRequestActionLogAddRelationshipSubscription</ManagementPackName>
      <ManagementPackVersion>7.0.5826.0</ManagementPackVersion>
    </Category>
    <Category ID=”Category.ServiceRequestActionLogAddRelationshipSubscriptionRule” Target=”ServiceRequestActionLogAddRelationshipSubscriptionRule” Value=”Administration!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions” />
  </Categories>
  <Monitoring>
    <Rules>
      <Rule ID=”ServiceRequestActionLogAddRelationshipSubscriptionRule” Enabled=”true” Target=”ServiceRequest!System.WorkItem.ServiceRequest.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.WorkItemHasCommentLog’]$” SourceType=”$MPElement[Name=’WorkItem!System.WorkItem’]$” TargetType=”$MPElement[Name=’WorkItem!System.WorkItem.TroubleTicket.UserCommentLog’]$”>
                <AddRelationship />
              </RelationshipSubscription>
              <PollingIntervalInSeconds>30</PollingIntervalInSeconds>
              <BatchSize>100</BatchSize>
            </Subscription>
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID=”WA” TypeID=”Subscriptions!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction”>
            <Subscription>
              <EnableBatchProcessing>false</EnableBatchProcessing>
              <WindowsWorkflowConfiguration>
                <AssemblyName>Microsoft.EnterpriseManagement.WorkflowFoundation</AssemblyName>
                <WorkflowTypeName>Microsoft.EnterpriseManagement.WorkflowFoundation.ConfigurationWorkflow</WorkflowTypeName>
                <WorkflowParameters>
                  <WorkflowParameter Name=”InstanceId” Type=”guid”>$Data/BaseManagedEntityId$</WorkflowParameter>
                  <WorkflowParameter Name=”InstanceTemplate” Type=”guid”>F473AAAF-8B64-2100-723D-40F7CF62C069</WorkflowParameter>
      <WorkflowParameter Name=”NotificationRulesEnabled” Type=”boolean”>False</WorkflowParameter>
                </WorkflowParameters>
                <RetryExceptions />
                <RetryDelaySeconds>60</RetryDelaySeconds>
                <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
              </WindowsWorkflowConfiguration>
            </Subscription>
          </WriteAction>
        </WriteActions>
      </Rule>
    </Rules>
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID=”ENU” IsDefault=”true”>
      <DisplayStrings>
        <DisplayString ElementID=”LumagateServiceRequestActionLogAddRelationshipSubscription”>
          <Name>Lumagate Service Request Action Log Add Relationship Subscription</Name>
        </DisplayString>
        <DisplayString ElementID=”ServiceRequestActionLogAddRelationshipSubscriptionRule”>
          <Name>Service Request Action log entry added to action log</Name>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>

 

7 Responses to Notify Assigned to when the Affected User updates a Service Request from the SSP in SCSM 2012

  1. Boris Petrov says:

    This solution works perfectly, but I am experiencing some difficulties defining the notification template. How can I create a notification template which sends only the last comment. I am trying to use the “ Work Item Comments Log” class as a target class in the template and using the “ Work Item Has Comment Log” related class (EnteredDate, EnteredBy, Comment properties). The thing is that email is empty at the end. Probably I am not doing something right. Can you advise me how to create a notification template which send only the last comment added. Thank you.

    • Anders Asp says:

      Hi Boris,

      As of now this is not possible to do within Service Manager – you would have to create your own custom workflow to achieve this.

      Regards
      //Anders

  2. GillesP says:

    Thanks for this very interresting blog.
    But i would like to Notify Affected User when Assigned to updates a Service Request from Console.
    Is it possible ? if yes, how ?
    Thanks.

  3. Anders Asp says:

    GillesP

    So whenever a technician updates the SR from the console you want the Affected User to get a notification?

    Regards
    //Anders

  4. Chris Stelzer says:

    What target class should I be using for the notification template? I’ve tried the “Trouble Ticket User Comments”, as i’ve done for Incidents, but when the template is e-mailed out, all my variables are blank (ie. Title, ID, etc).

    Do you have an example of your notification template?

  5. chwilówki says:

    Hi there, I enjoy reading all of your article.I like to write a little comment to support you.

Leave a Reply

Your email address will not be published. Required fields are marked *


*