I'm using a couple of scripts to automate a workflow we are using. The workflow is as follows :
A user requests access to a certain system, He or she has to fill in 2 fields, 1 dropdown and 1 multiline. Both are custom fields. Upon submitting the request, SDP asks for an approval to the user's manager. Depending on getting an approval or not, SDP sends an email to the department that grants the access or sends a mail to the user that the approval is denied and in both cases it adds a note with the taken action to the request. We use Powershell for this.
However, when the user uses linebreaks in the multilined field, the script breaks because somehow the API does not accept the JSON, because of the linebreaks. So the script is executed, but nothing happens because of the linebreaks. If we manually remove the linebreaks and run the script again, everything is fine. Due to the amount of tickets that we get, we really like to automate this. Is there a way to use a multilined field with the API. The JSON we are generating is below
- #=======================================================================
- # Add Request fields values
- #=======================================================================
- $workorderid = $obj.request.WORKORDERID
- $requester = $obj.request.REQUESTER
- $Systemtyperequest = $obj.request."Tot welk systeem vraag je toegang"
- $Queuename = $obj.request."Welke Queues in Blue heb je nodig?"
- #=======================================================================
- # Setting Reply settings
- #=======================================================================
- $replyurl = $sdphost + "sdpapi/request/" + $workorderid
- $replymethod = "POST"
- $replyoperation = "REPLY_REQUEST"
- $Replyreciever = "reciever email"
- #=======================================================================
- # Configure the textinput for the reply
- #=======================================================================
- $replydescription = "$requester heeft toegang gevraagd tot het systeem $Systemtyperequest. Hij wil graag toegang tot de volgende queues: $Queuename."
- #=======================================================================
- #Configure input data for adding a reply
- #=======================================================================
- $replyinputdata = @"
- {
- "operation": {
- "details": {
- "to": "$Replyreciever",
- "cc": "",
- "subject": "[Request ID:##$workorderid##] Aanvraag Toegang Blue/Parley/Obi4wan/Bas",
- "description": "$replydescription"
- }
- }
- }
- "@
- #=======================================================================
- # Sending Reply
- #=======================================================================
- $replyparams = @{INPUT_DATA=$replyinputdata;OPERATION_NAME=$replyoperation;TECHNICIAN_KEY=$techkey;format='json'}
- Invoke-WebRequest -Uri $replyurl -Method $replymethod -Body $replyparams
- #=======================================================================
- # Setting Notes settings
- #=======================================================================
- $notesurl = $sdphost + "sdpapi/request/" + $workorderid + "/notes"
- $notesmethod = "POST"
- $notesoperation = "ADD_NOTE"
- #=======================================================================
- # Configure the textinput for the note
- #=======================================================================
- $notescontent = "$requester wil in het systeem $Systemtyperequest toegang tot de queue $Queuename. De aanvraag is doorgestuurd naar het volgende adres: $Replyreciever"
- #=======================================================================
- # Configure input data for adding note to request
- #=======================================================================
- $notesinputdata = @"
- {
- "operation": {
- "details": {
- "notes": {
- "note": {
- "ispublic": "false",
- "notestext": "$notescontent"
- }
- }
- }
- }
- }
- "@
- #=======================================================================
- # Sending Notes
- #=======================================================================
- $noteparams = @{INPUT_DATA=$notesinputdata;OPERATION_NAME=$notesoperation;TECHNICIAN_KEY=$techkey;format='json'}
- Invoke-WebRequest -Uri $notesurl -Method $notesmethod -Body $noteparams
Edit : We are using SDP version 10.0 Build 100200 on Postgres