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

how to do substring of an attribute passed in the Create account JSON of REST connector

VamsheeVazza
New Contributor II
New Contributor II

Hi 

I have a case where i'm getting a full text of a location in runtime which i need to pass to create account JSON from creation task.
but the create task only needs first part before '-'.
How can i do a substring in the JSON to just pass the first part of the string to the task.
below is the example

requestAccessAttributes.get('Service_Location') is "ACT2 - ACT Customer Service Supervisor"

i just need to pass ACT2 to the JSON.

 

 

Create account JSON

{
"accountIdPath": "call1.message.userId",
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://xxxxxxxx/csp/v1/user/users",
"httpMethod": "POST",
"httpParams": "{\"userId\": \"${user.customproperty1}\",\"roleNames\": [],\"workLocationCode\": \"${requestAccessAttributes.get('Service_Location')}\",\"emailAddress\": ${if(user.email != null || user.email != \"\"){'\"' +user.email+ '\"'}else{user.email}},\"firstName\": \"${user.firstname}\",\"lastName\": \"${user.lastname}\",\"accessList\": [${requestAccessAttributes.get('SpAccess')}],\"status\": \"Active\"}",
"httpHeaders": {
"Authorization": "${access_token}",
"X-Agent": "xxxxx",
"X-Channel": "xxxxx",
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201,
202
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,
403,
404,
429,
500,
503
]
}
}
]
}

 

I tried  \"${requestAccessAttributes.get('Service_Location').replace(requestAccessAttributes.get('Service_Location').substring(requestAccessAttributes.get('Service_Location').indexOf('-')-1), '')}\" instead of  \"${requestAccessAttributes.get('Service_Location')}\"

Still no Luck.

Can some one help what wil be the good syntax to achieve this.

6 REPLIES 6

rushikeshvartak
All-Star
All-Star

Use java substring 

 

 

${requestAccessAttributes.get('Service_Location').substring(0, requestAccessAttributes.get('Service_Location').substring(requestAccessAttributes.get('Service_Location').indexOf('-')+ 1))}


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

Not sure how will it pull the first 4 char of the string.

Did you tried above suggested logic ?


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

${requestAccessAttributes.get('Service_Location').substring(0,4)}


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

The 4 should not be hardcoded. it should be derived from the position of '-' in the string.

${requestAccessAttributes.get('Service_Location').substring(0, requestAccessAttributes.get('Service_Location').substring(requestAccessAttributes.get('Service_Location').indexOf('-')+ 1))}


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