Share via


SCSM: Add User Input to Description Field for Incidents from Portal


Introduction

Have you ever noticed that Service Requests have the user input from the portal on the front of the ticket but Incidents don't.  If you're like most users of SCSM you have probably extended the incident or service request class with some generic fields so you can ask more questions on the portal and have fields to map to, if not I'll save that for another post.

Overview of Runbook

We are going to use a little Orchestrator and Powershell magic for this.  First you will need to add a Runbook activity to the incident template you will be using for portal incidents.  Here is a birds eye view of the runbook and we will go over each IP individually.

https://automationwoes.files.wordpress.com/2016/02/parse-user-input.jpg?w=2038

Creating Runbook

We are going to start with the initialize data IP.  You are just going to pass the Runbook Activity ID into the initialize data IP.  I'm going off the assumption you already know how to trigger a runbook from SCSM but if not leave a comment and I will go further into detail.  We are going to pass that RB ID into the Get RBA Object IP as so.

https://automationwoes.files.wordpress.com/2016/02/get-rba.jpg?w=1324

Now we need to get the relationship of the Runbook Activity to the incident.

https://automationwoes.files.wordpress.com/2016/02/ralated.jpg?w=1272

As you can see, I am using Extension of Incident Related Class because that is what I called my class when I extended it.  FYI, I extended it to 30 generic text fields and 2 generic date time fields for growth and for those of you that where wondering.  These fields can be seen on the extension tab of the incident ticket but nobody wants to click over there to see the info and they are generic fields so the labels are meaningless to techs.

Now lets get the IR

https://automationwoes.files.wordpress.com/2016/02/get-ir.jpg?w=1270

When you are choosing the value make sure to use RELATED OBJECT GUID not Relationship Object GUID.  Relationship will get you nowhere in this scenario.

Now here comes the PowerShell magic.  Parse User Input into Array.  You will use the Run .Net IP here and choose Powershell as Type.  Your details tab will look as so

https://automationwoes.files.wordpress.com/2016/02/run-net.jpg?w=1274

and your Published Data tab will look as so

https://automationwoes.files.wordpress.com/2016/02/published-data.jpg?w=878

And here is the magic code to pull it all together

$UserInput= '{User Input from "Get IR"}'

$nl = [Environment]::NewLine

$content=[XML]$UserInput

$inputs = $content.UserInputs.UserInput

foreach ($input in $inputs)

{

if($($input.Answer) -like "<value*")

{

[xml]$answer = $input.answer

foreach($value in $($($answer.values)))

{

foreach($item in $value)

{

foreach ($txt in $($item.value))

{

$ListArray += $($txt.DisplayName)

}

$Array += $input.Question + " = " + [string]::Join(" ; ",$ListArray) +$nl

$ListArray = $null

}

}

}

else

{

if ($input.type -eq "enum")

{

$ListGuid = Get-SCSMEnumeration -Id $input.Answer

$Array += $($input.Question + " = " + $ListGuid.displayname) +$nl

}

else

{

$Array += $($input.Question + " = " + $input.Answer) +$nl

}

}

}

$Array

{User Input from "Get IR"} will be replaced with the variable of the same name from the Get IR IP.  Make sure to leave it in the single quotes.

Next we will pass the $Array variable into the Update Description IP mapped to the description field of the incident.

https://automationwoes.files.wordpress.com/2016/02/update-description.jpg?w=1290

And for good measure we will update the Runbook Activity to complete so we don't have to wait for the SCSM workflows to do it for us.  Just makes things a little quicker.  

https://automationwoes.files.wordpress.com/2016/02/update-activity.jpg?w=1334

Just remember when creating a IR for the Portal don't map anything to the description field.  Map everything to the generic fields unless it pertains to a specific field like priority then map that to priority.  I think you get the jist.  If done correctly you will get something like this.

Completed Process

https://automationwoes.files.wordpress.com/2016/02/description.jpg?w=772

There is also an additional comments piece below the transaction date but as you know the incident description field only scrolls and doesn't expand like the SR description field does.  That is a post for another day. But alas, viola, there you have it.  All the information your tech needs right in the description field.

Summary

​​​This will help your technicians tremendously when working with service request in Service Manager, putting all information where it is expected to be.

See Also