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

In Rest connector-userimportjson using #const# dont update if target value is null

sampath18
Regular Contributor II
Regular Contributor II

Hi,

we want to fetch the inbetween value ,after open parenthesis "(" and before underscore "_" from the Customfields-->value and we are able fetch the value using below logic in userimportjson(rest connector). 

 

"customproperty11": "#CONST#${String RTNSponsor = response['Custom Fields'][0].value;int underscoreIndex = RTNSponsor.indexOf('_');int parenthesisIndex = RTNSponsor.indexOf('(');String beforeUnderscore = RTNSponsor.substring(parenthesisIndex + 1, underscoreIndex);return beforeUnderscore}~#~char"

 

Postman response:-

"Custom Fields": [
                {
                    "name": "RTN Sponsor",
                    "module": "Work Order",
                    "value": "Abujbara, Tala (44806_BNCO)"
                }
 
but its updating the CP11 with the logic as it is if no value in "value":  
 
"Custom Fields": [
{
"name": "RTN Sponsor",
"module": "Work Order",
"value": ""
},
 
sampath18_0-1710490069809.png

I have tried multiple if and else logic but for them same issue and even not updating for the value which is present.

Some logic tried:-

1."customproperty11": "#CONST#${String RTNSponsor = response['Custom Fields'][0].value;if (!String.IsNullOrEmpty(RTNSponsor)){int underscoreIndex = RTNSponsor.indexOf('_');int parenthesisIndex = RTNSponsor.indexOf('(');String beforeUnderscore = RTNSponsor.substring(parenthesisIndex + 1, underscoreIndex);return beforeUnderscore;} return RTNSponsor;}~#~char"

 

2."customproperty11": "#CONST#${String RTNSponsor = response['Custom Fields'][0].value;if (RTNSponsor != null){int underscoreIndex = RTNSponsor.indexOf('_');int parenthesisIndex = RTNSponsor.indexOf('(');String beforeUnderscore = RTNSponsor.substring(parenthesisIndex + 1, underscoreIndex);return beforeUnderscore;} return '';}~#~char"

 

3."customproperty61": "#CONST#${String RTNSponsor = response['Custom Fields'][0].value;int underscoreIndex = RTNSponsor.indexOf('_');int parenthesisIndex = RTNSponsor.indexOf('(');String beforeUnderscore = '';if (RTNSponsor != null && RTNSponsor.length() > 0 && underscoreIndex > 0 && parenthesisIndex > 0) {beforeUnderscore = RTNSponsor.substring(parenthesisIndex + 1, underscoreIndex);}return beforeUnderscore;}~#~char"

 
 
 
 
1 REPLY 1

sampath18
Regular Contributor II
Regular Contributor II

Able to achieve this using below logic:-

"customproperty11": "#CONST#${(response['Custom Fields'][0].value == '') ? '' : response['Custom Fields'][0].value.substring(response['Custom Fields'][0].value.indexOf('(') + 1, response['Custom Fields'][0].value.indexOf('_'))}~#~char",