How to change incident status when end user updates incident

Answered How to change incident status when end user updates incident

  • Tuesday, May 08, 2012 12:54 AM
     
     

    Hi,

    For an incident, after we click 'Request User Input' and type a comment, an email is sent to the end user with our comment and the status of the incident is changed to 'Pending'.

    How can we change the status of the incident back to 'active' once the end user has updated the incident?

    I have tried to create a incident workflow but the 'Action Log' classes are not present to leverage in the incident workflow.

    Any ideas?

    Thanks.

All Replies

  • Tuesday, May 08, 2012 4:08 AM
    Moderator
     
      Has Code

    Export the MP containing the workflow and change the data source to this:

    <DataSource ID="DS" TypeID="SystemCenter1!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
      <Subscription>
        <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicketHasUserComment']$" SourceType="$MPElement[Name='CoreIncident!System.WorkItem.Incident']$" TargetType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicket.UserCommentLog']$">
          <AddRelationship />
        </RelationshipSubscription>
        <PollingIntervalInSeconds>10</PollingIntervalInSeconds>
        <BatchSize>100</BatchSize>
      </Subscription>
    </DataSource>

    Every time the user adds a comment, this workflow should trigger. If you set the workflow to apply a template to change the status to active, then this should work ok.

    Alias - WorkItem is System.WorkItem.Library and CoreIncident is System.WorkItem.Incident.Library.


    Rob Ford scsmnz.net


  • Tuesday, May 08, 2012 4:27 AM
     
     

    Hi Rob,

    Thanks for the suggestions, however could you please provide me with some more detail instrcution. New to the SCSM authoring tool and am finding it a little ticky to follow your suggestion.

    Thanks for your help!

  • Tuesday, May 08, 2012 6:56 AM
    Moderator
     
     

    The easy way is to not use the AT and create a new Workflow in a new MP:

    1. Create a workflow for incident update triggered on any criteria (you'll replace the criteria) that applies a template that just sets the status to Active. Create this new workflow in a new Management Pack.

    2. Export the new Management Pack XML somewhere.

    3. Edit the XML and replace the Subscription section for the DataSource (not the WriteAction) with the subscription section only from the above code I gave you.

    4. Check what the alias for the reference at the top for "System.WorkItem.Incident.Library" is. It will probably be something like "CustomSystem_WorkItem_Incident_Library". Replace "CoreIncident" with this alias.

    5. Import the modified Management Pack.

    To test, update an incident as a user from the portal by adding a comment. This will create a new user comment relationship and should trigger the workflow which will reset the status back to Active.


    Rob Ford scsmnz.net


  • Tuesday, May 08, 2012 7:02 AM
    Moderator
     
      Has Code

    Sorry, forgot, you'll also need to add this reference:

    <Reference Alias="WorkItem">
            <ID>System.WorkItem.Library</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
    </Reference>
    Note - version is 2012, change to 2010 version if needed (or probably just 1.0.0.0 will work)

    Rob Ford scsmnz.net


  • Tuesday, May 08, 2012 7:05 AM
    Moderator
     
     Answered Has Code

    Complete MP example, tested and is working, but note that you'd need to change the Guid for your InstanceTemplate:

    <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>ManagementPack.3fec88d02de04b6ab6a3e94bfc63b346</ID>
          <Version>7.5.1561.0</Version>
        </Identity>
        <Name>Test Workflows</Name>
        <References>
          <Reference Alias="EnterpriseManagement">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</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="CustomSystem_WorkItem_Incident_Library">
            <ID>System.WorkItem.Incident.Library</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="EnterpriseManagement1">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="IncidentManagement">
            <ID>ServiceManager.IncidentManagement.Library</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemCenter">
            <ID>Microsoft.SystemCenter.Subscriptions</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
        </References>
      </Manifest>
      <Categories>
        <Category ID="Category.df27287780654e1a8e95d442e5dbced7" Value="EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack">
          <ManagementPackName>ManagementPack.3fec88d02de04b6ab6a3e94bfc63b346</ManagementPackName>
          <ManagementPackVersion>7.5.1561.0</ManagementPackVersion>
        </Category>
        <Category ID="Category.3c54612a71114c0bb5d5a300f1065e81" Target="WorkflowSubscription_81146cd4_9efe_49e4_a504_b654b5c7bbf1" Value="EnterpriseManagement1!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions" />
      </Categories>
      <Monitoring>
        <Rules>
          <Rule ID="WorkflowSubscription_81146cd4_9efe_49e4_a504_b654b5c7bbf1" Enabled="true" Target="IncidentManagement!System.WorkItem.Incident.Wizard.AutomaticChangeIncident" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
            <Category>System</Category>
            <DataSources>
              <DataSource ID="DS" TypeID="SystemCenter!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
                <Subscription>
                  <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicketHasUserComment']$" SourceType="$MPElement[Name='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']$" TargetType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicket.UserCommentLog']$">
                    <AddRelationship />
                  </RelationshipSubscription>
                  <PollingIntervalInSeconds>10</PollingIntervalInSeconds>
                  <BatchSize>100</BatchSize>
                </Subscription>
              </DataSource>
            </DataSources>
            <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <VisibleWorkflowStatusUi>true</VisibleWorkflowStatusUi>
                  <EnableBatchProcessing>true</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows.AutomaticIncidentChangeWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowArrayParameter Name="InstanceIds" Type="guid">
                        <Item>$Data/BaseManagedEntityId$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowParameter Name="InstanceTemplate" Type="guid">308a72ea-493b-552e-9afc-9c0a19867728</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="ManagementPack.3fec88d02de04b6ab6a3e94bfc63b346">
              <Name>Test Workflows</Name>
            </DisplayString>
            <DisplayString ElementID="WorkflowSubscription_81146cd4_9efe_49e4_a504_b654b5c7bbf1">
              <Name>Sample Incident Workflow</Name>
            </DisplayString>
          </DisplayStrings>
        </LanguagePack>   
      </LanguagePacks>
    </ManagementPack>


    Rob Ford scsmnz.net



  • Tuesday, May 08, 2012 7:07 AM
     
     

    Thanks Rob!!!

    I will give this a try shortly and let you know if it works for me.

    Really appreciate your help and detailed instrcution.

  • Tuesday, May 08, 2012 9:00 AM
     
     

    Hi !

    Did you try this ?

    http://www.scsm.se/?p=167

    Roman


    Problem talk creates problems, solution talk creates solutions (Steve deShazer)

  • Wednesday, May 09, 2012 12:52 AM
     
     

    Thanks Rob, all tested and working!

    We did have to create a new management pack, then export, then copy the datasource section from your exported example in our MP. The datasource sample in your first post did not work, however it did from your second larger MP xml file.

    Thanks for spoon feeding us!

    :)

  • Wednesday, May 09, 2012 10:49 PM
     
     

    Worked perfect for me.

    Is it possible to generate the same workflow to mark incident status as "wait for user comment" when analyts  updated the action log

    Thanks for your help

    Rahul


    Rahul Paul

  • Wednesday, May 09, 2012 10:56 PM
    Moderator
     
     
    Some solution really, if you setup a workflow that applies an incident template that sets the status accordingly with some dummy criteria, you can export the MP and update the DataSource section with the one above, except that you want to use the relationship called "System.WorkItem.TroubleTicketHasAnalystComment".

    Rob Ford scsmnz.net

  • Thursday, May 10, 2012 12:00 AM
     
     

    Thanks for the reply. 

    I tried the solution you recommended but workflow  seems to be doing nothing. i cannot see anything in under workflow status . My management pack is as follow

    <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>ManagementPack.87ea0cdc76fd43dda6959b38ca2e929b</ID>
          <Version>7.5.1561.0</Version>
        </Identity>
        <Name>CDM-IncidentStatusUpdate-WaitForComment</Name>
        <References>
          <Reference Alias="EnterpriseManagement">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="CustomSystem_WorkItem_Incident_Library">
            <ID>System.WorkItem.Incident.Library</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="IncidentManagement">
            <ID>ServiceManager.IncidentManagement.Library</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="CustomSystem_WorkItem_Library">
            <ID>System.WorkItem.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="EnterpriseManagement1">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemCenter">
            <ID>Microsoft.SystemCenter.Subscriptions</ID>
            <Version>7.5.1561.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
        </References>
      </Manifest>
      <Categories>
        <Category ID="Category.6295caf4906b404f98d6f91d47e3ac87" Value="EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack">
          <ManagementPackName>ManagementPack.87ea0cdc76fd43dda6959b38ca2e929b</ManagementPackName>
          <ManagementPackVersion>7.5.1561.0</ManagementPackVersion>
        </Category>
        <Category ID="Category.bfb2b3a0ae634ea6bbd2fa9b7f8f7717" Target="WorkflowSubscription_56bc51b0_c131_4955_8bf8_1975bb5904e2" Value="EnterpriseManagement1!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions" />
      </Categories>
      <Monitoring>
        <Rules>
          <Rule ID="WorkflowSubscription_56bc51b0_c131_4955_8bf8_1975bb5904e2" Enabled="true" Target="IncidentManagement!System.WorkItem.Incident.Wizard.AutomaticChangeIncident" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
            <Category>System</Category>
            <DataSources>
            <DataSource ID="DS" TypeID="SystemCenter!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
                <Subscription>
                  <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicketHasAnalystComment']$" SourceType="$MPElement[Name='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']$" TargetType="$MPElement[Name='WorkItem!System.WorkItem.TroubleTicket.AnalystCommentLog']$">
                    <AddRelationship />
                  </RelationshipSubscription>
                  <PollingIntervalInSeconds>10</PollingIntervalInSeconds>
                  <BatchSize>100</BatchSize>
                </Subscription>
            </DataSource>
            </DataSources>
            <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <VisibleWorkflowStatusUi>true</VisibleWorkflowStatusUi>
                  <EnableBatchProcessing>true</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows.AutomaticIncidentChangeWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowArrayParameter Name="InstanceIds" Type="guid">
                        <Item>$Data/BaseManagedEntityId$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowParameter Name="InstanceTemplate" Type="guid">80d89379-a0b7-1662-f10f-7a015ac9b7da</WorkflowParameter>
                      <WorkflowParameter Name="NotificationRulesEnabled" Type="boolean">False</WorkflowParameter>
                    </WorkflowParameters>
                    <RetryExceptions />
                    <RetryDelaySeconds>60</RetryDelaySeconds>
                    <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
                  </WindowsWorkflowConfiguration>
                </Subscription>
              </WriteAction>
            </WriteActions>
          </Rule>
        </Rules>
      </Monitoring>
      <Templates>
        <ObjectTemplate ID="Template.2343a2e0aa5044e3a790c5bd8bbe95e0" TypeID="IncidentManagement!System.WorkItem.Incident.ProjectionType">
          <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Escalated$">False</Property>
          <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Status$">fe88458e-6f7c-2477-efcc-30b9f102884f</Property>
          <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/NeedsKnowledgeArticle$">False</Property>
          <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/HasCreatedKnowledgeArticle$">False</Property>
        </ObjectTemplate>
      </Templates>
      <LanguagePacks>
        <LanguagePack ID="ENU" IsDefault="false">
          <DisplayStrings>
            <DisplayString ElementID="ManagementPack.87ea0cdc76fd43dda6959b38ca2e929b">
              <Name>CDM-IncidentStatusUpdate-WaitForComment</Name>
            </DisplayString>
            <DisplayString ElementID="Template.2343a2e0aa5044e3a790c5bd8bbe95e0">
              <Name>CDM-IncidentStatusUpdate-Analyst-WaitforComment</Name>
            </DisplayString>
            <DisplayString ElementID="WorkflowSubscription_56bc51b0_c131_4955_8bf8_1975bb5904e2">
              <Name>CDM-IncidentStatusUpdate-Analyst-WaitForComment</Name>
            </DisplayString>
          </DisplayStrings>
        </LanguagePack>
        <LanguagePack ID="ENA" IsDefault="false">
          <DisplayStrings>
            <DisplayString ElementID="Template.2343a2e0aa5044e3a790c5bd8bbe95e0">
              <Name>CDM-IncidentStatusUpdate-Analyst-WaitforComment</Name>
            </DisplayString>
            <DisplayString ElementID="WorkflowSubscription_56bc51b0_c131_4955_8bf8_1975bb5904e2">
              <Name>CDM-IncidentStatusUpdate-Analyst-WaitForComment</Name>
            </DisplayString>
          </DisplayStrings>
        </LanguagePack>
      </LanguagePacks>
    </ManagementPack>


    Rahul Paul

  • Thursday, May 10, 2012 12:23 AM
    Moderator
     
     

    Hi Rahul, Your MP as shown doesn't import because you have 2 references for System.WorkItem.Library, I've fixed this up and changed the InstanceTemplate Guid to one of mine and the work flow triggers.

    When testing, are you adding an analyst comment or an action log comment? They are 2 difference classes...

    Did you import via a console or powershell running on the workflow server or another server? For example, if you have a console running on a secondary server and add a new workflow, the workflow servers tends not to see the new workflow until it's cache updates or the services are restarted, at least, this is how it used to be on 2010, I don't have this setup to test on 2012.


    Rob Ford scsmnz.net



  • Thursday, May 10, 2012 1:13 AM
     
     

    Management pack did   imported succesfully previously. So in  this management pack do i need to remove the reference as you suggested

    Not sure which class i am manipulating , but basic idea  i am working on is to change the incident status to " Wait for user coment " if  analyst add comment  from  console or via email. not sure which class it is

    And i have imported the management pack via console

    Apprecate your help

    Thanks

    Rahul


    Rahul Paul

  • Thursday, May 10, 2012 1:31 AM
    Moderator
     
      Has Code

    Basically, if you remove this from the MP you posted:

    <Reference Alias="CustomSystem_WorkItem_Library">
      <ID>System.WorkItem.Library</ID>
      <Version>7.5.1561.0</Version>
      <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
    </Reference>
     

    And then change the guid value for "InstanceTemplate" to the Guid of your template that sets the status to what you want, it should work ok.

    You can get the guid for your template by looking at ObjectTemplateId in the ObjectTemplate table.

    But - bear in mind that there are 3 log classes in Service Manager. Your MP is monitoring just "System.WorkItem.TroubleTicket.AnalystCommentLog". These are the comments entered by an analyst, for example, via the console. There is also the action log class (normally comments added by workflows) and user comment class (comments added by a user from the portal).


    Rob Ford scsmnz.net

  • Thursday, May 10, 2012 1:52 AM
     
     

    Thanks Rob it is working now


    Rahul Paul

  • Thursday, May 10, 2012 2:04 AM
    Moderator
     
     
    Does that mean I get 2 answers for the same question? :P

    Rob Ford scsmnz.net

  • Thursday, October 25, 2012 2:58 PM
     
     
    Any way to add a restriction to this workflow, so the incident only flips to "Active" when it's currently in a "Pending" state??? The issue with this is when the user gets a "Resolved" e-mail, and replies with "Thank You", that End User comment is triggered and the Incident is flipped back to "Active". Just uncovered this issue during our implementation, works great otherwise!
  • Thursday, October 25, 2012 5:33 PM
    Moderator
     
     
    That's not possible. The challenge is to create a filter/logic that is analyzing the text of the mail and make a decision. For instance: "this isn't still working ... but thanks for your support" ... "Thanks" ... "Thanks but there is still the same issue" ... "Tahnks" .... and so on.

    Andreas Baumgarten | H&D International Group