Home Service Manager

How SCSM Workflow triggers on Workitem Status Changed

Jan_SchulzJan_Schulz Customer Adept IT Monkey ✭✭

Hi,

is it possible to trigger every time when a workitem status changed. So it would monitor the property status.

I cant find a generic way to solve this.

Best Answer

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Answer ✓

    Here we go @Jan_Schulz

    Here's an example for Incident Status. The first expression covers the 'Null' to 'Something' scenario and the second covers 'Anything' to 'Anything Else'.

    <InstanceSubscription Type="$MPElement[Name='Incident!System.WorkItem.Incident']$">
      <UpdateInstance>
        <Criteria>
          <Expression>
            <Or>
              <Expression>
                <And>
                  <Expression>
                    <UnaryExpression>
                    <ValueExpression>
                      <Property State="Pre">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                    </ValueExpression>
                    <Operator>IsNull</Operator>
                    </UnaryExpression>
                  </Expression>
                  <Expression>
                    <UnaryExpression>
                    <ValueExpression>
                      <Property State="Post">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                    </ValueExpression>
                    <Operator>IsNotNull</Operator>
                    </UnaryExpression>
                  </Expression>
                </And>
              </Expression>
              <Expression>
                <SimpleExpression>
                <ValueExpression>
                  <Property State="Pre">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                </ValueExpression>
                <Operator>NotEqual</Operator>
                <ValueExpression>
                  <Property State="Post">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                </ValueExpression>
                </SimpleExpression>
              </Expression>
            </Or>
          </Expression>
        </Criteria>
      </UpdateInstance>
    </InstanceSubscription>
    

    As above, you need to manually manipulate the management pack XML. I would probably create my workflow with any random criteria, export the MP and edit the code within the InstanceSubscription tags to the above. Then reimport.

    Good luck!

Answers

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭

    I'm leaning with there probably isn't a single workflow approach way to solve this because Work Items don't share Status enums. For some supporting evidence, attempting to build a Workflow in the SCSM Authoring Tool around the System.WorkItem class doesn't even let you pick the property because it's not defined at System.WorkItem but instead on a per class level.

    That said, you'd have to have a Workflow for each Work Item class whose Status you want to monitor.

    The only Work Item class that shares a Status enum is the Activity class (Review, Manual, Parallel, etc.)

  • Jan_SchulzJan_Schulz Customer Adept IT Monkey ✭✭
    edited October 2021

    Hi @Adam_Dzyacky ,


    thank you for the answer. I was not accurate enough.

    it is not generally about all workitems together but only about certain ones like SR and IR.

    For example with a service request I would like to trigger only when the status changes. but I can only select from in status and not generally any change to the property status of the SR. As I understand it I would have to create a separate SR workflow for each possibility (for example Status Active to Status Hold, Status Active to Status Closed and so on) then just to not trigger on every change of the SR to e.g. title etc. Maybe it's easier than I think but I somehow can't figure it out.


    regards,

    Jan

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.

    Hi @Jan_Schulz

    I'm not aware of any UI that supports this (console / Authoring Tool) but I'm pretty sure this is possible directly in the UI. You can do something like 'Pre State' does not equal 'Post State'.

    It covers any change to the property. I'll try and track down an example.

    Geoff

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Answer ✓

    Here we go @Jan_Schulz

    Here's an example for Incident Status. The first expression covers the 'Null' to 'Something' scenario and the second covers 'Anything' to 'Anything Else'.

    <InstanceSubscription Type="$MPElement[Name='Incident!System.WorkItem.Incident']$">
      <UpdateInstance>
        <Criteria>
          <Expression>
            <Or>
              <Expression>
                <And>
                  <Expression>
                    <UnaryExpression>
                    <ValueExpression>
                      <Property State="Pre">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                    </ValueExpression>
                    <Operator>IsNull</Operator>
                    </UnaryExpression>
                  </Expression>
                  <Expression>
                    <UnaryExpression>
                    <ValueExpression>
                      <Property State="Post">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                    </ValueExpression>
                    <Operator>IsNotNull</Operator>
                    </UnaryExpression>
                  </Expression>
                </And>
              </Expression>
              <Expression>
                <SimpleExpression>
                <ValueExpression>
                  <Property State="Pre">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                </ValueExpression>
                <Operator>NotEqual</Operator>
                <ValueExpression>
                  <Property State="Post">$Context/Property[Type='Incident!System.WorkItem.Incident']/Status$</Property>
                </ValueExpression>
                </SimpleExpression>
              </Expression>
            </Or>
          </Expression>
        </Criteria>
      </UpdateInstance>
    </InstanceSubscription>
    

    As above, you need to manually manipulate the management pack XML. I would probably create my workflow with any random criteria, export the MP and edit the code within the InstanceSubscription tags to the above. Then reimport.

    Good luck!

  • Jan_SchulzJan_Schulz Customer Adept IT Monkey ✭✭

    @Geoff_Ross thank you. This was the missing link :-)

    this community is the best i know. Thank you so much.

Sign In or Register to comment.