{"id":3142,"date":"2012-10-16T21:56:49","date_gmt":"2012-10-16T19:56:49","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=3142"},"modified":"2012-10-16T21:56:49","modified_gmt":"2012-10-16T19:56:49","slug":"pass-information-between-runbook-activity","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=3142","title":{"rendered":"Pass information between runbook activity"},"content":{"rendered":"<p>In Service Manager 2012 we can use runbooks from Orchestrator as activity in for example a service request template. This brings a lot of cool possibilities for automation in your data center. I have\u00c2\u00a0blogged\u00c2\u00a0a number of examples around this that you can find here on the blog. But in most of the examples I use only one runbook activity, and if I need to use multiple runbooks they are all started from one &#8220;master&#8221; runbook, not as\u00c2\u00a0individual\u00c2\u00a0activities in the service request template. \u00c2\u00a0I came across a scenario where we needed to use multiple runbook activities in the same service request template and we needed to pass information between the runbook activities. One benefit with splitting multiple runbooks into multiple runbook activities is that it is easier to track the result in Service Manager, when each step in a complex workflow is its own runbook activity. This also gives the benefit that a Service Manager operator can re-start\/re-run a step if needed.<\/p>\n<p>In this blog I will show how you can use two runbook activities in a service request and pass information from runbook activity one to runbook activity two. We will also see how the result from both runbook activities can be published in the service request and self-service portal. In my demo example the first runbook generates an &#8220;account name&#8221; and the second runbook generates a &#8220;phone number&#8221;.<\/p>\n<p>Each instance of a runbook activity have a number of &#8220;generic\/blank&#8221; fields that we will use to store the result, they are for example named TEXT1 to TEXT10. Why not store the result in the Service Request? Even if the service request have some fields I could use I don&#8217;t want to do that as it would be difficult to remember what result I store in which property. An alternative would be to extend the service request class, but that would result that all kind of service requests would get those new properties, as they use the same service request class.<\/p>\n<p>The first runbook, in this example named 12.1, has one input parameter which is the runbook activity ID. The runbook then generates an account (random 4 characters) and returns account name back to Service Manager.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3314\" title=\"20121016_PassData01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData01-300x91.jpg\" alt=\"\" width=\"300\" height=\"91\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData01-300x91.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData01.jpg 431w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In Service Manager I have configured that OUT from this runbook should be written to the TEXT1 field of the runbook activity instance. This is done in the service request template, on the runbook activity.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData02.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3315\" title=\"20121016_PassData02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData02-300x191.jpg\" alt=\"\" width=\"300\" height=\"191\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData02-300x191.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData02.jpg 729w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The second runbook, in this example named 12.2, have one input parameter which is the runbook activity ID. The runbook then generates a phone number (random numbers). Then it gets a bit more complicated \ud83d\ude42<\/p>\n<ul>\n<li>Get Related Service Request. This activity use the input parameter, the runbook activity instance ID, to get the related Service Request.<\/li>\n<li>Get Service Request. This activity gets the Service Request that the previous activity found<\/li>\n<li>Get Related Runbook Activities. This activity finds all related runbook activities to the service request. We need to do this as we need to find the first runbook activity and read the TEXT1 field.<\/li>\n<li>Get Runbook Activities. The &#8220;Get Related Runbook Activities&#8221; will return all related runbook activities, in this example there are two runbook activities in the service request. The link after the &#8220;Get Runbook Activities&#8221; activity is configured with a filter to only continue with the runbook activity that that a specific title. This title is the title you configure in the service request template.<\/li>\n<li>Update Imp Result. This activity update the service request with both a implementation result and an new description. Implementation result and description are both visible\u00c2\u00a0in the Service Manager console. The description field is also visible in the self-service portal.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData03.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3317\" title=\"20121016_PassData03\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData03-300x41.jpg\" alt=\"\" width=\"300\" height=\"41\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData03-300x41.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData03.jpg 620w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData04.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3318\" title=\"20121016_PassData04\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData04-300x141.jpg\" alt=\"\" width=\"300\" height=\"141\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData04-300x141.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData04.jpg 601w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData05.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3319\" title=\"20121016_PassData05\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData05-300x144.jpg\" alt=\"\" width=\"300\" height=\"144\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData05-300x144.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData05.jpg 603w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData06.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3320\" title=\"20121016_PassData06\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData06-300x115.jpg\" alt=\"\" width=\"300\" height=\"115\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData06-300x115.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData06-1024x394.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData06.jpg 1222w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData07.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3321\" title=\"20121016_PassData07\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData07-300x252.jpg\" alt=\"\" width=\"300\" height=\"252\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData07-300x252.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/10\/20121016_PassData07.jpg 432w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Service Manager 2012 we can use runbooks from Orchestrator as activity in for example a service request template. This brings a lot of cool possibilities for automation in your data center. I have\u00c2\u00a0blogged\u00c2\u00a0a number of examples around this that you can find here on the blog. But in most of the examples I use &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=3142\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[60,25],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3142"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3142"}],"version-history":[{"count":9,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3142\/revisions"}],"predecessor-version":[{"id":3324,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3142\/revisions\/3324"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3142"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}