How to identify rejected scsm service requests
The back story behind this is pretty lengthy, so I'll just ask the question first:
Is there a way (powershell or otherwise in Orchestrator) to identify failed Service Requests that have failed because their Review Activity was Rejected?
Now for the reason...
I have implemented 2 runbooks,
- One to find failed Review Activities - this then changes the SR status to Cancelled and skips the outstanding activities
- The second to find all failed SRs - this then reopens the SR and moves to the Service Desk to investigate
I don't want the second runbook to be picking up the SRs that are failed due to being Rejected.
Thanks.
Best Answer
-
Konstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭In your second runbook, you could Get Relationship to RA and flatten the activity, and then get the array of Related Object GUIDs in a PS script activity, loop through it, and if you find a RA with status failed, set a published variable to e.g. false, and set a filter on the next link, which leads to the rest of the runbook, to only continue if that variable is not false.
Script for getting status of RA from GUID could be something like this (with SMLets):<br>ipmo smlets<br><br># Continue runbook by default<br>$continueRunbook = $true<br><br># Create array from GUIDS from returned data from Get Relationship activity<br>$RAGuids = '[RelatedObjectGuid from Get RA Relationships Activity]'.Split(",")<br><br># Get each RA and check if status if failed<br>foreach($RAGuid in $RAGuids)<br>{<br> $status = (Get-SCSMObject -Id $RAGuid).Status.Name<br> <br> if($status -eq "ActivityStatusEnum.Failed")<br> {<br> $continueRunbook = $false <br> }<br>}<br>
And the runbook itself would be something like this:
6
Answers
- Are they all SRs of a particular "type" (i.e. title, description, area, etc.) or are they ALL failed service requests?
I ask as it will certainly change the scope of the input in that the pool of work items to plow through will be either all failed or all failed with some additional criteria. I only ask this terms of a "processing time", but once you get your dataset you'll need to do something to the following effect:So the first line you get have your SR, the second line gets you the related objects to that SR whose class name equals Review Activity. However what I think the problem here is going to be is your two aforementioned runbooks. If this is happening, you're already changing the "shape" of your data which renders my above idea a bit moot. In which case you're going to have to get more creative and turn to Get-SCSMObjectHistory.
Hopefully I haven't entirely missed you're question?
Hi @Adam_Dzyacky
Thanks for the reply, processing time should be fine as the first step (entry point) is a Monitor Object step in the runbook, this just monitors for updated failed service requests.
SCSMObjectHistory sounds like it might be a good area to explore. I'll take a look.
It would be all Failed SR's, so I need the powershell to check for rejected RA's.
Would your PowerShell then be able to go further to check for a rejected status? It's this bit that I'm struggling with.
Script for getting status of RA from GUID could be something like this (with SMLets):
And the runbook itself would be something like this:
That's what I needed, thanks @Konstantin_Slavin-Bo
I had tried the get what you've specified, but had got stuck at the bit to check the status, so it was this bit I needed:
$status = (Get-SCSMObject -Id $RAGuid).Status.Name
Thank you!
Great, happy to help!