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

Remove brackets from Service Account Owner attributes in JSON

nvachhani
Regular Contributor
Regular Contributor

How can brackets be removed from Service Account Owner attribute values when provisioning to AD? 

Example:

 

{
  "info": "Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('26').collect{it.customproperty3.toString()}}",
  "sn": "${ServiceAccountOwnerMap.get('USEROWNERS').get('26').collect{it.lastname.toString()}}",
  "givenName": "${ServiceAccountOwnerMap.get('USEROWNERS').get('26').collect{it.firstname.toString()}}"
}

Values sent to AD look like following:

Owner  - [custprop3value]

[lastnamevalue]

[firstnamevalue]

 

I have tried the following:

"Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.custom property3.toString().replace("[", "").replace("]", "")}}",

"Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.custom property3.toString().replace(\"[\", \"\").replace(\"]\", \"\")}}",

"Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.custom property3.toString().replace(\\\"[\\\", \\\"\\\").replace(\\\"]\\\", \\\"\\\")}}",

These result in error: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript14.groovy: 14: unexpected char: '\' 

I have also tried single quotes around the bracket but that does not do anything and value still ends with brackets around it.

"Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.customproperty3.toString().replace('[', '').replace(']', '')}}",
3 REPLIES 3

rushikeshvartak
All-Star
All-Star

Sample

 

${entitlement_values.collect{it.toString().indexOf("(") == -1 ? it : it.toString().substring(0, it.toString().indexOf("(") -1)}.toListString().replaceAll('\\[|\\]','')}

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

nvachhani
Regular Contributor
Regular Contributor

The following still does not strip the brackets:

"info": "Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.customproperty3.toString().replaceAll('\\[|\\]','')}}",

 

 

"info": "Owner - ${ServiceAccountOwnerMap.get('USEROWNERS').get('1').collect{it.customproperty3}.toString().replaceAll('\\[|\\]','')}",

 


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