Skip tasks [MA] depending on the value of user prompt

Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
edited July 2017 in Service Manager
Hi, I try to make automation in service request  in which user order service for specified period. 
When they make an request they have to fill the prompts - fields:
1. Device number
2. What to do (enumeration list) with service, values:
  2.1. Turn on and turn off
  2.2. Only turn on
  2.3. Only turn off
3. Turn on date - wisible only where option 2.1 and 2.2 was choosen (invisible when choose option 2.3)
4. Turn off date - wisible only where option 2.1 and 2.3 was choosen (invisible when choose option 2.2)

My serivce template include 2 Manual acctivities:
MA1.  Turn on date
MA2.  Turn off date

How to, in simple way, to: skip/cancel/don't register unnecessary activity - according to value choosen from list?

I try to make dependent prompts and map it into status of activity but in map window, there aren;t any option to set default value for field with MA status. 
Is there other option than PS activity or is PS only option, could someone give some script, help?

Best Answers

Answers

  • Eric_KrasnerEric_Krasner Customer Advanced IT Monkey ✭✭✭
    edited July 2017
    The way i do this is in an Orchestrator Runbook.  Based on the value (which is mapped to an extended field) i then set the MA to Status = Skipped. (Of course you first have to filter to get the correct MA, then you can updated the object with the status).
  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
    Great. Thanks for info. Do you know good tutorial that show, how to set flow of request in simplest way. Honelsty, I'm new with SMA, PS, SCORCH.
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited July 2017
    So for SMA, I've created a new runbook that has a single parameter ($runbookID), and runs a script against my SCSM workflow server. This runbook is now sitting in SMA waiting to be called and I'm not exactly interested in using the SMA portal to start the runbook. Luckily that's where the Cireson SMA Connector comes into play.
    workflow Test-Runbook
    {
        param(
        # 'RunbookID' is the ID of the Runbook passed/mapped from the SCSM Template
        [parameter(Mandatory=$true)]
        [String]$runbookID
        )
    
        $scsm = Get-AutomationConnection -Name 'Name of your SCSM Cred Object in SMA'
    
        inlinescript
        {
            #declare classes
            $srClass = get-scsmclass -Name "system.workitem.servicerequest$" 
            $paclass = get-scsmclass -Name "system.workitem.activity.parallelactivity$" 
            $saClass = get-scsmclass -Name "system.workitem.activity.sequentialactivity$" 
            $smaClass = get-scsmclass -name "System.WorkItem.Activity.SMARunbookActivity$" 
            $skippedEnum = get-scsmenumeration -Name "ActivityStatusEnum.Skipped$"
    
            #get the runbook
            $rb = get-scsmobject -class $smaClass -filter "Name -eq '$using:RunbookID'"
    
            #with the runbook, you can now swing around the object in SCSM
            #going to parent work items, related activities, other objects on the RB, etc.
            #You will probably need to declare those classes upfront as well
            $relatedThings = Get-SCSMRelationshipObject -ByTarget $runbookID
    
            #get the SCSM Work Item Objects
            $sr = get-scsmobject -id (get-scsmrelationshipobject -ByTarget $rb).sourceobject.id 
            $pa = get-scsmrelatedobject -smobject $sr | ?{$_.ClassName -eq "System.WorkItem.ParallelActivity"}
    
            #pick the SA to skip path within the PA
            if (<#some condition#>)
            {
                $sa = get-scsmrelatedobject -SMObject $pa | ?{$_.title -eq "Sequential Activity Path 1"}
                set-scsmobject -SMObject $sa -Property Status -Value $skippedEnum
            }
            else
            {
                $sa = get-scsmrelatedobject -SMObject $pa | ?{$_.title -eq "Sequential Activity Path 2"}
                set-scsmobject -SMObject $sa -Property Status -Value $skippedEnum
            }
    
        } -PSComputerName $scsm.ComputerName -PSCredential $scsm.Credentials
    }

    Now you'll create an SCSM template based on this SMA runbook. So leaving the SMA Portal and heading back to Service Manager:
    Library -> New Template -> SMA Runbook class

    The runbook you'll use is the one you recently published in the SMA portal. You can now map properties into it. In this example, you'd map the Work Item ID to the RunbookID parameter. Now when the Runbook Activity is called, it kicks off the SMA runbook with the Work Item ID being fed in as a parameter. But you still aren't done yet.

    With the new Runbook Activity, go back to your template that you're building your process for and add a new activity. You can now select the runbook activity template you just created and place it somewhere in your process stream. Beginning. Middle. End. Wherever you want/need.


    NOTE: 
    This isn't a fully functioning runbook. It's more of an example of what the PowerShell would look like/a general idea of how you could go about this with SMA and the Cireson SMA Connector. I should add, there is a Cireson support KA roughly outlining the same thing here https://support.cireson.com/KnowledgeBase/View/18#/. Since you're just getting started, I'd strongly advocate for getting SMlets installed and begin trying to perform simple Get operations against SCSM via PowerShell. There are a lot of articles on SMlets from Travis, here's one that should help you get started: https://blogs.technet.microsoft.com/servicemanager/2011/04/21/using-smlets-beta-3-post-1-using-get-scsmobject-get-scsmclass-to-dump-data-from-scsm/

    If you're still hazy on any of this, I can certainly expand further. 
  • Ian_StephensonIan_Stephenson Customer IT Monkey ✭
    Would anyone be willing to share or show how they did this in Orchestrator? We do not have SMA set up yet at our organization, and our experience with Orchestrator is minimal at best. I think I understand some of what I need to create for this to work, but don't fully know what all needs to be built into the Runbook.
Sign In or Register to comment.