Our System Center Memo

SCSM Adding Dynamic Activities

Sometimes we want to dynamically add activities depending on what the user selects in a Service Request. If you’ve tried using SCSM’s template to do this you’ll realize that the activities added will be in a mess and it won’t work. You’re going to need to rely on SCO for this.

I’m posting this under the assumption that you know a little bit about SCO, if not, let me know and I’ll guide you separately. If there’s enough volume I’ll write a comprehensive guide.

In this guide, I will be using a PowerShell script NOT WRITTEN by myself, I’m not sure where it originated from, so credits to whoever wrote it.

  1. First build a SCO Runbook, it may look something like this. You’ll need to parse the SR ID and the SC Object Guid of the Service Request into the Initialize Data activity.
  2. Under Details, paste the script below.

    $Session = New-PSSession -ComputerName ‘Your SCSM MS Name
    $SeqNo = Invoke-Command -Session $Session -scriptblock{

    Import-Module SMLets
    # Define Service Request
    # Get Service Request Class
    $SRclass = Get-SCSMClass -Name System.WorkItem.ServiceRequest$ 
    # Get object relationship 
    $SRMAObjectRelClass = Get-SCSMRelationshipClass System.WorkItemContainsActivity
    # Get SR Object
    $SRobject = Get-SCSMObject -Class $SRclass -Filter "ID -eq $SR"
    $Activityobjects =  @(Get-SCSMRelatedObject -SMObject $SRobject -Relationship $SRMAObjectRelClass )
    $Seq = $Activityobjects.count
    Remove-PSSession $Session
    Remove-Module SMlets -Force

  3. Under Published Data, add the following.
  4. Add the Create Related Object activity into the Runbook and set it following the screenshot below. For ID, if you leave the it at {0}, it will use the latest available ID number, which is what you want. But make sure you add the prefix such as MA or RA behind or you’ll end up with a ticket number without a prefix.
  5. Using this method you can now dynamically add a MA or RA, and it will be added according to the sequence you want, instead of it randomly being arranged on your workflow.

July 17, 2014 - Posted by | System Center Orchestrator (SCO), System Center Service Manager (SCSM)

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: