Home Analyst Portal

For ARO service request with multiple MA's

alex_kokinalex_kokin Member IT Monkey ✭

For ARO service request with multiple MA's. Is there a way to delete or close any unused MA's in the RO?

I have different MA activities depending on user results and I need to be able to close or remove the un-selected MA's


or even better yet, is there an option to create a MA dynamically depending on end user responses?

Answers

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited May 19

    ARO doesn't have this kind of logic control.

    I think your best bet (and something I myself have done) is using ARO to map to all possible outcomes (MAs). Then with Orchestrator, SMA, or PowerShell Activity conditionally control whether or not those MAs get Skipped. Just make the runbook the very first activity so it does all of the shaping of the request at the outset.

    Depending on the shape of your request, let's say several of these MAs are contained within a single PA or SA. The runbook would just have to Skip the SA/PA and native SCSM would then skip all contained Activities.

  • alex_kokinalex_kokin Member IT Monkey ✭

    I am not much of a powersheller, do you by chance have a script that can just delete any MA with a null title? I really appreciate your response.

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited May 19

    You don't want to delete, you may think you do (I know I did once!) but you don't. Just hear me out -

    If you delete a Work Item out of SCSM, you will have zero means to determine what happened to it because you no longer have auditing of that thing. So the only thing left here is to infer what could have happened to it and that uncertainty isn't something you want when you have hundreds or thousands of Request Offerings, Incidents, Problems, Changes, and all of the other moving parts of SCSM.

    So instead - Skip. This way you'll have the ability to slice your reporting really easily e.g. "ignore all Skipped". You'll maintain the audit history of that object - did SCSM skip it? or did an analyst skip it? And if someone makes a mistake, you'll have to opportunity to return to a Skipped activity (again whether that was done by an Analyst or SCSM).


    To Skip a Manual Activity, the following PowerShell (via SMLets) looks something like this:

    $maClass = Get-SCSMClass -Name "System.WorkItem.Activity.ManualActivity$"
    $ma = Get-SCSMObject -class $maClass -filter "Name -eq 'MA12345'"
    Set-SCSMObject -smobject $ma -PropertyHashtable @{"Status" -Value "ActivityStatusEnum.Skipped$"; "Skip" = $true}
    

    In these two lines you're first saying

    1. I want to work with all Manual Activities
    2. then I want to work with one specific Manual Activity in the system
    3. finally Mark the Activity as Skipped

    The thing is, this really just skips a single MA whose ID you already know which doesn't do much good given your current situation. Because people will submit requests and the IDs will always be different. So what you need to do is place yourself in the context of a submitted request. The only thing you know if you were the first Activity in a Request is your own ID and Class. SCO, SMA, or PSA let you pass the current ID as an input to the automation. Depending on which one of these 3 technologies you use, choosing that input is going to be ever so slightly different. So I'll preface the next part that complexity scales a bit from the above example:

    $runbookClass = Get-SCSMClass -name "System.WorkItem.Activity.SMARunbookActivity$"
    $runbook = Get-SCSMObject -class $runbookClass -Filter "Name -eq $TheMappedInputParameter"
    $parentSRRelationship = get-scsmrelationshipobject -bytarget $ra  | where-object {$_.SourceObject.ClassName -eq 'System.WorkItem.ServiceRequest'}
    $parentSR = get-scsmobject -id $parentSRRelationship.SourceObject.Id 
    $childMARelationships = get-scsmrelationshipobject -bysource $parentSR
    $childMAs = $childMARelationships | foreach-object {Get-SCSMObject -id $_.SourceObject.Id } | Where-Object {$_.ClassName -eq 'System.WorkItem.Activity.ManualActivity'}
    $childMAsWithoutTitles = $childMAs | Where-Object{$_.Title -eq $null}
    $childMAsWithoutTitles | Foreach-Object{Set-SCSMObject -smobject $_ -PropertyHashtable @{"Status" -Value "ActivityStatusEnum.Skipped$"; "Skip" = $true}
    

    As you can see it starts kind of similar. What happens next I generally pull up the UI so I can follow along with how to swing from the runbook to around the Work Item I'm contextually working in.

    1. We want to work with the runbook class
    2. then a specific runbook by the ID that we map into it
    3. we get all of the relationships to the runbook (this could be the parent work item, the assigned to user on the runbook, the impacted CIs on the Related Items tab, etc.) Since we only want 1 of those relationships (the one that binds the runbook to the parent SR) we filter that accordingly with the pipe | and where-object
    4. We then get just the SR from the relationship in step 3
    5. With the new SR, we get all of the relationships to it. Again, this could be the related items tab, the assigned to user, the affected user, etc. On line 5, we just get all of those things
    6. With all of those relationships, we now filter them down to just the ones that are Manual Activities
    7. Then for all the Manual Activities we have, we filter down again for all of the ones that have a Title that is null
    8. Finally - for each Manual Activity that doesnt have a title, we Skip it


    Hope this helps

  • alex_kokinalex_kokin Member IT Monkey ✭

    Thank you very much...

    Any chance of just using this portion without runbooks?


    $parentSRRelationship = get-scsmrelationshipobject -bytarget $ra  | where-object {$_.SourceObject.ClassName -eq 'System.WorkItem.ServiceRequest'}
    $parentSR = get-scsmobject -id $parentSRRelationship.SourceObject.Id 
    $childMARelationships = get-scsmrelationshipobject -bysource $parentSR
    $childMAs = $childMARelationships | foreach-object {Get-SCSMObject -id $_.SourceObject.Id } | Where-Object {$_.ClassName -eq 'System.WorkItem.Activity.ManualActivity'}
    $childMAsWithoutTitles = $childMAs | Where-Object{$_.Title -eq $null}
    $childMAsWithoutTitles | Foreach-Object{Set-SCSMObject -smobject $_ -PropertyHashtable @{"Status" -Value "ActivityStatusEnum.Skipped$"; "Skip" = $true}
    


  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭

    You'd need to tweak the initial input of this PowerShell to get it working with PowerShell Activity which is essentially a runbook.

Sign In or Register to comment.