Cancel pending activities in a failed Service Request

Travis Wright has a couple of years ago, written a blog on how to cancel pending activities in a failed Change Request:

I often get the request to make a similar solution for Service Requests and thought it was about time to document it. 

Open the Authoring console and create a new Management Pack.

Right-click on Workflows and select Create

Give the workflow a name:


Choose to trigger the workflow based on a condition occurring in the database:

And subscribe to Service Requests being updated where the criteria is Status BEFORE Not Equal to Failed and Status AFTER Equal to Failed.



 Then finish out the wizard.

That will drop you into the workflow designer. Drag a single PowerShell script activity from the
toolbox onto the workflow designer and give it a name:



Then click thebutton on the Script Body attribute in the Details pane and insert the Powershell script.



Here is the script so you can copy it if you want to:

import-module smlets
$InProgress = Get-SCSMEnumeration -Name ActivityStatusEnum.Ready

$Cancelled = Get-SCSMEnumeration -Name ActivityStatusEnum.Cancelled

$ServiceRequest = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "Id -eq $ServiceRequestID"

$ChildActivities = (Get-SCSMRelationshipObject -BySource $ServiceRequest |?{$_.RelationshipID -eq "2da498be-0485-b2b2-d520-6ebd1698e61b"})

$ChildActivities | %{$Activity = Get-SCSMObject -ID $_.TargetObject.Id; if($Activity.Status -eq $InProgress){$Activity | Set-SCSMObject -Property Status -Value $Cancelled}}


Then you need to bind the ID of the Service request that triggers the workflow to the $ServiceRequestID variable. To do this switch to the Script Properties tab. Enter ‘ServiceRequestID’
in the Name column (so that it exactly matches the name of the $ServiceRequestID variable in the PowerShell script) and then click the … button and choose the ID property (not ID (Internal)).





Now save the management pack. That will produce a .dll file that contains the workflow code.

To deploy the slution:

Import the MP into SCSM and Copy the .dll to C:\Program Files\Microsoft System Center 2012\Service Manager  directory on the SCSM management server where the workflows are running.

First, here’s an SR waiting for an approval:


Let’s play along and deny the request. Normally the SR would fail and the remaining activites will stay in Pending mode.


Now, with the new Workflow in place, the remaining activites are changed from Pending to Cancelled.


So like with the CR activities, you can actually restart the Review Activity and all the Manual activites
will go back to pending, awaiting the RA to be approved.


Attached is the MP and DLL I've created as I wrote this blog.


Comments (8)
  1. Jon says:

    Doesn’t work for me. I have checked the code in PS – works fine. Workflow result is succeeded but no changes to Activity

  2. Jon says:

    Works fine. Sorry: i have used Travis’ post and replaced CRs with SRs like Thomas did but i could have made a mistake somewhere. Recreated the MP and it works fine. Thanks Thomas

  3. mike says:

    How would we go back and cancel all of the pending activities from all failed SRs? This workflow is great for ones that are create after I implemented the workflow. However I have a mess of pending activities that are cluttering up our views.

  4. Greg Lambert says:

    Hello, is this a SCSM 2010 or 2012 solution please? I have imported the management pack and placed the dll in C:Program FilesMicrosoft System Centre 2012Service Manger, but get an error on the workflow -2130771918 to the effect that the file could not
    be found, I assume it is referring to the dll, but not 100% sure. Any thoughts please?

  5. Chase says:

    Hi, I have another MP that changes the status of Denied SR’s from Failed to Rejected. I would like to use the MP you created to cancel the manual activities on these rejected SR’s.

    The Rejected status has been added to the Service Request Status list in the SCSM console, but I can’t select that as an option on changing criteria on the workflow of your MP. Any suggestions?

  6. lucy says:

    Great post from your hands again. I loved the complete article.
    By the way nice writing style you have. I never felt like boring while reading this article.

    I will come back & read all your posts soon. Regards, Lucy.

  7. showbox dl says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    Latest version of Showbox App download for all android smart phones and tablets. – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    Showbox for PC articles:
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android.
    The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.

Comments are closed.

Skip to main content