How to: Map Repeating Table Answers to SR field
Problem
The answers provided in a repeating table of a service request cannot be mapped to a field (e.g. Description) by default as shown below:
Repeating Table question with property "Name" and "Phone"
Service Request with two repeating table objects (Phone Nr. not displayed)
Submitted SR seen from Enduser Portal
Note that the values from repeating table are visible in User Input but not in Description
Workaround
The answers from the repeating table are stored in the Service Request UserInput property as xml and can therefore be retrieved using SMLets
A simple way to map those Userinputs to the Description field is by adding a Powershell activity that parses the xml data and updates the Description property as first Activity of that Service Request.
Example
This small example writes the repeating table answers into the Description property as name-value pair
- Open SCSM Console
- Select "Administration" Tab
- Select "PowerShell Scripts" > "All PowerShell Scripts"
- Select Task "Create PowerShell Script"
- Name your script
- Add the following script to "PowerShell Script Text":
try
{
Import-Module SMLets
#Get SCSMObject by guid
$objSR = Get-SCSMObject $rootId
#Extract Repeating Table Values from Userinput Property of SCSM Object as xml
$repeatingTable = ([xml]([xml]$objSR.UserInput).UserInputs.UserInput.Answer).UserInputs.UserInput
#Create string with values as name value pairs
$result = ""
ForEach($entry in $repeatingTable)
{
$result += $entry.Question
$result += ":`t"
$result += $entry.Answer
$result += "`n"
}
#create new property hash for Description property
$propertyHash = @{"Description" = $result}
#update Service Request with new Property
Set-SCSMObject -SMObject $objSR -PropertyHashtable $propertyHash
}
catch
{
Throw $Error[0].Exception
}
finally
{
Remove-Module SMLets
}
- Click "Apply" and "OK"
- In SCSM, Select "Library" Tab
- Select "Templates"
- Select Task "Create Template"
- Name your Template
- Select "Service Request" as "Class"
- Click "OK"
- Configure your Template as you please...
- Select "Activities" Tab of the Template
- Add a "Default PowerShell Activity" as first activity to your SR Template
- Name your Activity
- Add the previously created PowerShell Script to the Activity
- Click "OK"
- Click "OK"
- In SCSM console select "Service Catalog" > "Request Offerings" > "All Request Offerings"
- Select Task "Create RO for ITSM Portal"
- Name your RO
- Select the previously created Template as "Template name"
- Create two string user prompts named "Name" and "Phone"
- Configure the Prompts as you like (I left them in default config)
- Configure the Layout to hold both Prompts in the same repeating table
- Map the prompts to any property (otherwise you cannot save the new RO)
- Skip the Knowlede Articles config
- Set your offering status to "Published"
- Select a Service Offering
- Click "Create" to create your RO
- Done, go test your Offering in the Portal, wait for the Ps Activity to complete.
Service Request seen from EndUser Portal after PowerShell Activity completed