Earlier this week I needed to add a runbook activity to a Service Request depending on the result from a review activity. I have written about adding activities to a service request from a runbook before, here. The difference is that this time I needed to add a runbook activity and that is a bit more complicated than adding for example a review activity or manual activity.
To add a runbook activity you need two activities, first one that gets the runbook (System Center Orchestrator Runbook Item) you want to use, the second activity creates a new related runbook activity (Runbook Automation Activity) to the service request. In this example I will add a Runbook Automation Activity that runs a runbook named “12.4 Build new VM”.
For the Create Related RB activity there are more to configure compared with the “Get RB Item” activity.
- Source Object Guid. This is the SC Object GUID from a Get Object activity that gets the Service Request that we want to add a Runbook Automation Activity to.
- Sequence ID. This field configure where, compared with already existing activities in the Service Request, this new activity will be added. The first activity in a Service Request has sequence ID 0, the second 1 and so on. In my service request I have one review activity and then a runbook activity. This new runbook activity will be added after both of them, sequence ID 2 in other words.
- ID. This is the id of the new runbook activity. {0} will give it next free serial number from Service Manager, “RB” is added to make sure it is named not just a number but also RB in front of the number.
- Is Ready For Automation is set to TRUE. This will allow the Runbook Activity to be triggered when the Service Request is created and the Runbook Activity becomes In Progress.
- Title. Title of the runbook Runbook Automation Activity, for example “Build new VM”
- Runbook Identifier. This is the ID of the runbook you want to run, you get the ID from the previous Get RB Item activity.
- Template Identifier. This is a bit more complicated to find, this is the Name of the template you have built for the Runbook Automation Activity in Service Manager. If you start Service Manager Shell (Service Manager PowerShell) you can run “Get-SCSMObjectTemplate | ft Name, DisplayName” and you will find the value you need. Most likely your template name starts with Template.
- Status. Status of the new activity, configure it to Pending
-
Property Mapping. This is parameters that we pass to the new Runbook Automation Activity.
- <NAME> is the name of the input parameter in the runbook, the parameter set in in the Initialize Data activity
- <ID> is the ID of the parameter in Orchestrator. Each parameter has a unique ID. You can list get the connection between parameter, activity and runbook with the following SQL query. In my example query I ask for all input parameters named “SR”.
SELECT OBJECTS.Name AS [Activity Name], POLICIES.Name AS [Runbook Name], CUSTOM_START_PARAMETERS.UniqueID AS [Parameter ID], CUSTOM_START_PARAMETERS.Value AS [Parameter Name] FROM CUSTOM_START_PARAMETERS INNER JOIN OBJECTS ON CUSTOM_START_PARAMETERS.ParentID = OBJECTS.UniqueID INNER JOIN POLICIES ON OBJECTS.ParentID = POLICIES.UniqueID WHERE (CUSTOM_START_PARAMETERS.Value = ‘SR’)
- <VALUE> the value I pass to the new runbook is the Runbook Automation Activity ID. Based on that ID you can find the for example related service request
- <RunbookID> is the ID of the Runbook Item. You can get it from the Get Runbook activity or you can use Service Manager Shell to get it. To get it with Service Manager Shell run “Get-scsmclass –name Microsoft.SystemCenter.Orchestrator.RunbookItem | get-scsmclassinstance | where-object {$_.Name –like “*12.4*”} | ft Name, Id
In this example I ask for a runbook activity that I know is named something with 12.4.
Â
Those two activities is the two activities you need to add a Runbook Automation Activity. I notice that it works better if you also mark the current runbook as completed, from the runbook itself instead of from Service Manager. When adding activities in general I have notice that mark the current runbook as completed makes the service request process work better.
In the runbook you invoke you will get the Runbook Automation Activity SC GUID as input parameter. From there you can use a Get Relationship activity to find the related Service Request.
Â
Once you have the Service Request you can read for example all use input data, in my example settings for a new virtual machine. User Input, everything the user has input in for example the self-service portal when submitting the service request, is stored in XML format. For example
To get only “Stockholm” you can use a Query XML activity
Â
Â
Summary: In this blog post we have looked at how we can use a Runbook Automation Activity in a Service Request to add another Runbook Automation Activity. We have also looked at how to pass data to the new runbook. This scenario is useful if you for example want to add activities based on the answer from a review activity.
Hi Anders,
I sent you an email but I didn’t get a reply.
Could you send the runbook to my e-mail ?
robson.mcts at gmail.com
Tks in advance
Hi,
I have a question about the Property Mapping field. In the runbook activity template, I am mapping Work Item ID of Runbook Automation Activity to the Value field. I am unsure what do I replace “Generic::Id” with in order to get the correct value. I have tried Generic::Id but it doesn’t work. Can anyone please help?
Hi,
I don’t have more templates than what you can download from the blogpost, sorry. I don’t remember using a special template…
Hi Anders,
Do you have to have a template to apply to the Runbook Automation Activity (Template Identifier)? What info does the template have to have in order to make this work?
Thanks for your help.
Hi,
Send me a e-mail and I will look for it… Think I have it somewhere 🙂
Hello Anders,
Can you share that Runbook ?
In the property mapping field we put all settings to the new Runbook Automation Activity
I don’t think I understand and I’m not sure if someone could help me out. What exactly am I putting into the Property Mapping field? Do you just copy and paste that entire XML? Do I just put the one value that I want, which is the activity ID of the runbook?
Than you.
Hi, thanks for your feedback John, I will keep that in mind.
The suggestion to update the RB Activity in the runbook to completed status was a HUGE help!! That has substantially sped up my change process activities. I cant believe i didnt think of that. Thanks for the helpful blog.
I do consider all the ideas you’ve presented on your post. They’re really convincing and can certainly work. Still, the posts are very brief for novices. May just you please extend them a little from next time? Thanks for the post. babcdffkfbgd
Great articles Anders, very useful!