Click HERE to see how Saviynt Intelligence is transforming the industry. |
08/08/2024 03:29 AM
Hi,
We have a code that prints role specific business justification in rest connection (it is part of createticketjson code).
The code bit is like this:
${if(taskIds != null && taskIds.size()>0){String result='';ArrayList arr = new ArrayList(taskIds); arr.eachWithIndex{val, idx ->com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey!=null ? result=result.concat(com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey?.entitlement_value+': '+com.saviynt.ecm.task.ArsTasks.get(val)?.requestAccessKey?.comments.split(']')[1]):'';};return result;}else{return '';}}
However, the result gives an error as it has all these special character and html tags along with it. For reference PRC-CTMPROD_SCHEDULING and ctmdev_admin are roles and "test" is business justification:
PRC-CTMPROD_SCHEDULING: test</span><br/><span class="busjustformattask"></span><br/><span class="busjustformattask"></span>ctmdev_admin: test</span><br/><span class="busjustformattask"></span><br/><span class="busjustformattask"></span>
</span><br/><span class="busjustformattask"></span><br/><span class="busjustformattask"></span> : This part is redundant and causing trouble. Does anyone have help on what code to use to replace them with either blank or something like ||?
So far I have tried two ways using replace function but it is giving syntax error:
${if(taskIds != null && taskIds.size()>0){String result='';ArrayList arr = new ArrayList(taskIds); arr.eachWithIndex{val, idx ->com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey!=null ? result=result.concat(com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey?.entitlement_value+': '+com.saviynt.ecm.task.ArsTasks.get(val)?.requestAccessKey?.comments.split(']')[1].replace('</span><br/><span class="busjustformattask"></span><br/><span class="busjustformattask"></span>','')):'';};return result;}else{return '';}}
${if(taskIds != null && taskIds.size()>0){String result='';ArrayList arr = new ArrayList(taskIds); arr.eachWithIndex{val, idx ->com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey!=null ? result=result.concat(com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey?.entitlement_value+': '+com.saviynt.ecm.task.ArsTasks.get(val)?.requestAccessKey?.comments.replace('</span><br/><span class="busjustformattask"></span><br/><span class="busjustformattask"></span>','').split(']')[1]):'';};return result;}else{return '';}}
Does anyone have any help on the syntax?
Thanks in advance
Solved! Go to Solution.
08/08/2024 06:26 AM - edited 08/08/2024 06:27 AM
${if(taskIds != null && taskIds.size() > 0) {
String result = ''
ArrayList arr = new ArrayList(taskIds)
arr.eachWithIndex { val, idx ->
def task = com.saviynt.ecm.task.ArsTasks.get(val)
if (task?.entitlement_valueKey != null) {
def businessJustification = task?.requestAccessKey?.comments.split(']')[1]?.replaceAll('<[^>]*>', '').trim()
result = result.concat("${task?.entitlement_valueKey?.entitlement_value}: ${businessJustification} || ")
}
}
return result?.trim() ?: ''
} else {
return ''
}}
08/12/2024 03:30 AM
Had to edit your reference code but this works for our purposes:
${if(taskIds != null && taskIds.size()>0){String result='';ArrayList arr = new ArrayList(taskIds); arr.eachWithIndex{val, idx ->com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey!=null ? result=result.concat(com.saviynt.ecm.task.ArsTasks.get(val)?.entitlement_valueKey?.entitlement_value+': '+com.saviynt.ecm.task.ArsTasks.get(val)?.requestAccessKey?.comments.split(']')[1]?.replaceAll('<[^>]*>', ' ')):'';};return result;}else{return '';}}
08/12/2024 04:45 AM
✅Please click the 'Accept As Solution' button on the reply (or replies) that best answered your original question and hit 'Kudos' button 👍.