Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

Fetch Business Justification in Email-Template

tbhavya
New Contributor
New Contributor

Hi ,

I am trying to fetch the exact string entered in Business Justification in Email-Template .I tried using below :

<div><b>Business Justification:</b> ${accessItems.collect{it.comments.toString()}.toListString().replaceAll('\\[|\\]','')}</div>

However I'm getting the result of above, as timestamp + requestor + actual business justification text as shown below

Business Justification: 08/17/2022 UTC -Thummala Bhavya(tbhavya) Test email notification

I want only actual business justification text i.e., "Test email notification". How can we achieve this? Do we have any binding variable which can fetch only the business justification text?

Regards,

Bhavya.

5 REPLIES 5

rushikeshvartak
All-Star
All-Star

${accessItems.collect{it.comments.toString().substring(it.comments.toString().indexOf('UTC -')+it.comments.toString().length())}.toListString().replaceAll('\\[|\\]','')}


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

Hi Rushikesh,

Thanks for the response.

I tried this but getting an error.

tbhavya_0-1660833654139.png

I got below error in logs

java.lang.StringIndexOutOfBoundsException: String index out of range: -40
at java.lang.String.substring(String.java:1931)
at SimpleTemplateScript579$_run_closure2.doCall(SimpleTemplateScript579.groovy:20)
at SimpleTemplateScript579.run(SimpleTemplateScript579.groovy:20)
at com.saviynt.mail.EmailHistoryService$_execute_closure17.doCall(EmailHistoryService.groovy:2125)
at com.saviynt.mail.EmailHistoryService.execute(EmailHistoryService.groovy:1060)
at EmailHistoryJob.execute(EmailHistoryJob.groovy:30)

Regards,

Bhavya.

${accessItems.collect{it.comments.toString().indexOf("-") == -1 ? it.comments : it.comments.toString().substring( it.comments.toString().indexOf("-")+1)}.toListString().replaceAll('\\[|\\]','')}
 
 
rushikeshvartak_0-1660853757558.png

 


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

Hi Rushikesh,

It's partially worked I'm getting now below output.

Thummala Bhavya(tbhavya) Test email notification

The requirement was to print only "Test email notification" which we achieved using below configuration.

 ${accessItems.collect{it.comments.toString().substring(it.comments.toString().lastIndexOf(']')+1)}.toListString().replaceAll('\\[|\\]|\\n|\\r|\\t','')}

Regards,

Bhavya.

 

This won't work as user name will be dynamic & you can't assume comment some one can add () in comments 


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