{"id":2943,"date":"2012-04-11T09:51:09","date_gmt":"2012-04-11T07:51:09","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=2943"},"modified":"2012-04-11T09:51:09","modified_gmt":"2012-04-11T07:51:09","slug":"convert-a-incident-to-a-service-request-with-a-bit-of-orchestrator-magic","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=2943","title":{"rendered":"Convert a incident to a service request, with a bit of Orchestrator magic"},"content":{"rendered":"<p>A couple of days ago there was a question about converting a incident in Service Manager to a service request. The scenario was around a support call first register as an incident, but later the operator finds out it should be a service request. Out of the box in Service Manager there is no tool to move the data we have already input in the incident over to a new service request. But of course we could use Orchestrator to do it \ud83d\ude42 We could also build this workflow as an internal workflow in Service Manager&#8230; but that would take me a lot of hours; this runbook only took two cups of coffee. In this post I will show a idea how to build a task that you can run against a incident in Service Manager to &#8220;convert&#8221; it into a service request. The incident is not really converted, we copy the info we have in the incident over to a new service request, link them together and close the incident.<\/p>\n<p>The runbook is trigger by a task in Service Manager, input parameter is only the incident ID.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_013.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-2947\" title=\"20120411_01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_013-1024x207.jpg\" alt=\"\" width=\"1024\" height=\"207\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_013-1024x207.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_013-300x60.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_013.jpg 1129w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li>Initialize Data. Input parameter is IncidentID. ID of the incident we want to &#8220;convert&#8221; to a service request<\/li>\n<li>Get Object. Gets the incident from Service Manager. This step also verify that the incident\u00c2\u00a0don&#8217;t\u00c2\u00a0have Closed as status<\/li>\n<li>Send Platform Event. If the incident is closed or cant be found a platform event is generated. For example if you trigger the runbook with a incorrect incident ID from the Orchestrator console it will not run<\/li>\n<li>Get Relationship. Gets related Active Directory User to the incident<\/li>\n<li>Get Object. Gets the user that step 4 found<\/li>\n<li>Create Object. Creates a new service request and writes info to it from the incident<\/li>\n<li>Create Relationship. Create a\u00c2\u00a0relationship\u00c2\u00a0between between the service request and the affected user (relationship type = user)<\/li>\n<li>Create Relationship. Create a relationship between the service request and the incident (relationship class = is related to work item)<\/li>\n<li>Format Date\/Time. Gets the current time stamp in a correct format, will be used when creating comments on the incident and the service request<\/li>\n<li>Run .NET Script. A small PowerShell script that generates a GUID. The GUID will be used as ID for the incident comment<\/li>\n<li>Create Related Object. Creates a Trouble Ticket Action Log (action log comment) on and relates it to the incident. The runbook writes a comment saying the incident has been\u00c2\u00a0converted\u00c2\u00a0to a service request (relationship type = Trouble Ticket Has Action Log)<\/li>\n<li>Update Object. Resolve the incident, change status to Resolved<\/li>\n<li>Run .NET Script. A small PowerShell script that generates a GUID. The GUID will be used as ID for the service request comment<\/li>\n<li>Create Related Object. Creates a Trouble Ticket Analyst Comments (log comment) and relates it to the service request. The runbook writes a comment saying the service request was based on the incident<\/li>\n<li>Send Platform Event. Writes a platform event with service request ID and incident ID<\/li>\n<\/ol>\n<p>That is the runbook, the next component is the task in Service Manager. We could trigger the runbook from Orchestrator console and input the incident ID manually, but it is easier with a task in Service Manager. In the Service Manager console, in the Library workspace you can create a new task with the following settings.<\/p>\n<ul>\n<li>General\/Task name: Contoso -\u00c2\u00a0Convert Incident to Service Request<\/li>\n<li>General\/Target class: Incident<\/li>\n<li>Categories\/Categories: Incident Management Folder Tasks and Incident Support Groups Folder Tasks<\/li>\n<li>Command Line\/Full path to command:\u00c2\u00a0C:\\TEMP\\ORT251\\ORTRunbookLauncherCLI.exe<\/li>\n<li>Command Line\/Parameters:\u00c2\u00a0\/IncidentID=$Context\/Property[Type=&#8217;WorkItem!System.WorkItem&#8217;]\/Id$<br \/>\n(the parameter is the work item ID that you can insert from the \u00c2\u00a0&#8220;Insert Property&#8221; button)<\/li>\n<\/ul>\n<div>As you can see I use ORTRunbookLauncherCLI.exe to start the runbook. ORTRunbookLauncher.exe is part of <a href=\"http:\/\/orchestrator.codeplex.com\/releases\/view\/76983\">Orchestrator Remote Tool<\/a> that you can download from Codeplex.\u00c2\u00a0These tools provide a way to launch Orchestrator runbooks remotely from a UI or a command-line. Note that before you can run\u00c2\u00a0ORTRunbookLauncherCLI.exe\u00c2\u00a0you need to run ORTUIGenerator to generate a config (XML) file for the runbook you want to trigger. Lets look at a example<\/div>\n<div><\/div>\n<div>We select a incident and click the &#8220;Contoso &#8211; Convert incident to Service Request&#8221; task<\/div>\n<div><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_02.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter  wp-image-2950\" title=\"20120411_02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_02-1024x34.jpg\" alt=\"\" width=\"512\" height=\"34\" \/><\/a><\/div>\n<div>&#8230;the task starts and as we can see the task forward the incident ID to the runbook and starts the runbook<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_031.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2952\" title=\"20120411_03\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_031-278x300.jpg\" alt=\"\" width=\"278\" height=\"300\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_031-278x300.jpg 278w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_031.jpg 430w\" sizes=\"(max-width: 278px) 100vw, 278px\" \/><\/a><\/div>\n<div><\/div>\n<div><\/div>\n<p>&#8230;the runbook runs and generates a platform event<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_04.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2953\" title=\"20120411_04\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_04-300x269.jpg\" alt=\"\" width=\"300\" height=\"269\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_04-300x269.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_04.jpg 389w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&#8230;if we look at the incident it is now resolved and has a new comment<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_05.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2954\" title=\"20120411_05\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_05-300x42.jpg\" alt=\"\" width=\"300\" height=\"42\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_05-300x42.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_05.jpg 722w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&#8230;also a relationship to the new service request<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_06.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2955\" title=\"20120411_06\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_06-300x44.jpg\" alt=\"\" width=\"300\" height=\"44\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_06-300x44.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_06.jpg 676w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&#8230;and when look at the service request we can see that data has been copied over from the incident<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_07.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2956\" title=\"20120411_07\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_07-300x212.jpg\" alt=\"\" width=\"300\" height=\"212\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_07-300x212.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_07.jpg 417w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Summary: We have built a task in Service Manager that use the Orchestrator Remote Tool to trigger a runbook. The runbook connects to Service Manager, copies the data we have in the incident over to a new service request, resolve the incident and update both incident and service request with relationships and comments.<\/p>\n<p>You can download my runbook example here, <a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120410_Incident2ServiceReq_WOLF.zip\">20120410_Incident2ServiceReq_WOLF<\/a>.\u00c2\u00a0\u00c2\u00a0Please note that this is provided \u00e2\u20ac\u0153as is\u00e2\u20ac\u009d with no warranties at all.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of days ago there was a question about converting a incident in Service Manager to a service request. The scenario was around a support call first register as an incident, but later the operator finds out it should be a service request. Out of the box in Service Manager there is no tool &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=2943\">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\/2943"}],"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=2943"}],"version-history":[{"count":7,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2943\/revisions"}],"predecessor-version":[{"id":2962,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2943\/revisions\/2962"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2943"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}