and more in a single search tool across platforms. Read the announcement here. |
03/15/2024 01:16 AM
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:-
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"
Solved! Go to Solution.
03/15/2024 03:32 AM
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",