none
Update User input into Service request Description RRS feed

  • Question

  • I would like to update Service request's description with input enter by user while creating service request. In my case it is a Business justification which can be multiple line of text. 

    I followed one of the article from here http://itblog.no/4462, in fact in most of the article one powershell script is given which gives me error. the only difference here i have used "Run .NET script" instead of powershell 

    Error :- 

    Unexpected token 'Array' in expression or statement.

    $UserInput= '{UserInput from "Get Incident Request"}'

    $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

    is there any better idea or solution which can be used here ?



    Friday, August 2, 2019 11:49 AM

Answers

  • i am able to solve this by using below powershell

    $Var1 = ''

    $doc = [xml]$Var1

    $doc.UserInputs.UserInput[0].Question +" : "+ $doc.UserInputs.UserInput[0].Answer

    Friday, August 2, 2019 4:41 PM