Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Retain line break from " task.requestKey?.comments? "

xu
New Contributor II
New Contributor II

Hi Experts, 

Saviynt provisioning comments can be parsed through to a Jira ticket via the CreateTicketJSON, as below: 

 

 

Comments: ${task.requestKey==null?'':task.requestKey?.comments?.replaceAll('<.*?>','').replaceAll('[\\\\x0A\\\\x0D]', ' ').replaceAll('[^ -~À-ÿ]+','').replaceAll(new String('XFw='.decodeBase64()),new String('XFxcXA=='.decodeBase64()))}\"}
Spoiler
{
   "call":[
      {
         "name":"createTicket",
         "connection":"acctAuth",
         "url":"[URL]",
         "httpMethod":"POST",
         "httpContentType":"application/json",
         "httpParams":"{\"serviceDeskId\":\"20\",\"requestTypeId\":\"266\",\"requestFieldValues\":{\"summary\":\"DEV TICKET please ignore - ${endpoint.endpointname} Request\",\"description\":\"Saviynt User ID: ${user.username}\\\\n Saviynt Request ID: ${requestid}\\\\n Email: ${user.email}\\\\n \\\\n Entitlements:\\\\n ${allEntitlementsValues}\\\\n Endpoint: ${endpoint.endpointname}\\\\n Comments: ${task.requestKey==null?'':task.requestKey?.comments?.replaceAll('<.*?>','').replaceAll('[\\\\x0A\\\\x0D]', ' ').replaceAll('[^ -~À-ÿ]+','').replaceAll(new String('XFw='.decodeBase64()),new String('XFxcXA=='.decodeBase64()))}\"}}", 
         "ticketidPath":"issueKey",
         "httpHeaders":{
            "Authorization":"${access_token}"
         }
      }
   ]
}

 

the function .replaceAll('[\\\\x0A\\\\x0D]', ' ') is to ensure the  JSON is not broken by a line feed + carriage return. This obviously removes the line feed + carriage return, resulting in something similar as below, which is a bit difficult to read: 

xu_0-1717640744122.png

I am hoping that the line break entered before the words "NEW LINE" can be retained by means of something similar to .replaceAll('[\\\\x0D]', '\\\\n') (this did not work),  and if possible, have a line break between the different user's comments? 

Ideally, I would like the above output to look something like this: 

Comments: [04-Jun-2024 03:52:22 UTC -User(username)] please let this ticket work
NEW LINE to see if it can be parsed into Jira with spaces
[04-Jun-2024 04:03:06 UTC -User(username)] test
[04-Jun-2024 04:03:27 UTC -User(username)] test

Please let me know if this is feasible. 

Thank you in advance! 

2 REPLIES 2

Raghu
All-Star
All-Star

@xu  try double slash

Comments: ${task.requestKey==null?'':task.requestKey?.comments?.replaceAll('<.*?>','').replaceAll('[\\\\x0A\\\\x0D]', '\\n').replaceAll('[^ -~À-ÿ]+','').replaceAll(new String('XFw='.decodeBase64()),new String('XFxcXA=='.decodeBase64()))}\"}


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

rushikeshvartak
All-Star
All-Star

Refer https://forums.saviynt.com/t5/identity-governance/line-break-in-createticketjson-for-fresh-service/m...


Regards,
Rushikesh Vartak
If you find this response useful, kindly consider selecting 'Accept As Solution' and clicking on the 'Kudos' button.