Home Service Manager

RB to MA stuck in pending

Tom_HydeTom_Hyde Customer Advanced IT Monkey ✭✭✭

We have a set of RB's behind our CR to allow the status to be changed from 'In Progress' to a specific status e.g. 'CAB Approval' - when the automation task is completed the manual activity just sits on pending.

Is it possible to go directly from a completed RB activity to a MA? If not, how can we proceed to get this to work?

Thanks
Tom


Best Answer

Answers

  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    Aye, it indeed possible to go from a current "In Progress" runbook activity and start the next activity, bypassing the internal SCSM workflow process. As long as the activity SequenceIDs are set up properly, then the workflow process will resume working after that next MA is completed. Within the RBA, you would get all sibling activities, grab the one that has a SequenceID of one higher than the current runbook's SequenceID, and then set that MA to In Progress. Next, set the RBA status to Completed. 

    Are you looking for PowerShell code? Or scorch runbooks to do the trick?


  • Tom_HydeTom_Hyde Customer Advanced IT Monkey ✭✭✭
    Thanks for the response Jovian. The CR will go through a series of different status' (RB > MA > RB> MA) before if finally goes off to apply the change/release. Is this the best way of doing it out of curiosity? Its just you cant change the status of a CR like you can with other WI's e.g. IR, SR - Hence we have taken this approach.



    Looking for scorch runbooks ideally.
  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    I generally dislike using non-OOB statuses for activity-driven WIs. The workflow engine is temperamental when new statuses are used and sometimes doesn't know how to handle them. How mandatory are they in your environment? And/or could the custom status(es) be moved to a different field without much impact? 

    In scenarios like these where the workflow engine is stuck or is just ignoring work items, yep, you'll need a runbook or custom workflow to push it along. Something like a scheduled runbook or c#/PowerShell wf with a subscription or short timed schedule. 

    I do have a few PowerShell examples, but my native scorch runbook abilities are rather lacking. I'll have to defer to someone else. 
  • Tom_HydeTom_Hyde Customer Advanced IT Monkey ✭✭✭
    Not overly mandatory - The status(es) are generally there for Change Management to report and easily identify whats going on with a CR. I'm not too sure where else we can utilise the custom status(es) but this is an option if you know of one? as long as it still gives the functionality/visibility.
    If you can provide me with the PS examples then i can always give them a go also?
  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    I presume they dislike looking at the list of activities to check on the progress of the CR? You could also have the runbooks edit the title, description, or displayname fields. Though if it's affected by reporting (as compared to glancing at), I might suggest an extended enum field. 

    The PowerShell for obtaining and changing a status would work something like this:

    import-module smlets
    $ErrorActionPreference = "Stop"
    #Get classes
    $relWorkItemContainsActivity = Get-SCSMRelationshipClass -Name "System.WorkItemContainsActivity$"
    $clsRunbookActivity = Get-SCSMClass -Name "Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity$"
    #Get desired RB work item.
    $currentActivityID = "RB8104" #or, RB1234, etc.
    $currentActivity = Get-SCSMObject -Class $clsRunbookActivity -Filter "ID = $currentActivityID"
    #Get the parent work item.
    $parentChildWIRelObject = Get-SCSMRelationshipObject -TargetRelationship $relWorkItemContainsActivity -TargetObject $currentActivity
    $parentWorkItem = $parentChildWIRelObject.SourceObject
    #Get the activity that occurs next.
    $nextActivity = Get-SCSMRelatedObject -SMObject $parentWorkItem -Relationship $relWorkItemContainsActivity | where {$_.SequenceId -eq  $currentActivity.SequenceId + 1}
    #Set the status on the next workitem
    $propHash = (@{ Status = "In Progress" })
    Set-SCSMObject -SMObject $nextActivity -PropertyHashtable $propHash
    #Set the status on the current activity
    $propHash = (@{ Status = "Completed" })
    Set-SCSMObject -SMObject $currentActivity -PropertyHashtable $propHash


Sign In or Register to comment.