Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Need help with code bit to print business justification for roles

savuser17
Regular Contributor
Regular Contributor

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

3 REPLIES 3

rushikeshvartak
All-Star
All-Star

${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 ''
}}


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

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 '';}}

Please click the 'Accept As Solution' button on the reply (or replies) that best answered your original question and hit 'Kudos' button 👍.


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.