We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

Email template not being parsed: groovy.lang.GroovyRuntimeException

AS5278
Regular Contributor II
Regular Contributor II

I am trying to fetch Rejection Comments in an email template by using the below piece of code:

Request rejection comment -${def r=allRejectors.collect{it.username}.join(',').toString();r=r.replaceAll("[, ;]","");def ec=accessItems.collect{it.comments}.join(',').toString();def rc=ec.substring(ec.lastIndexOf(r+")] ")+(r+")] ").length());return rc;}

The email is not being parsed and I am getting the below error in logs:

{"log":"SimpleTemplateScript2576.groovy: 2: unexpected char: '\\' @ line 2, column 106.\n","stream":"stdout","time":"2023-01-19T19:01:34.270081009Z"}

I am not able to figure out what the issue is.

Any help would be appreciated.

Thanks.

 

xurde
5 REPLIES 5

sk
All-Star
All-Star

Can you paste the content of email template you have used?

Because as per logs it is complaining about \\ but don't see such character your expression.

Also did you try to break down the expression and see where it causing the issue?

Also what is the format you are trying to get as output


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

AS5278
Regular Contributor II
Regular Contributor II

Below is the email template:

<img alt="" src=""><br><br><div>Hi ${requestor.firstname} ${requestor.lastname},<br><br>Your request for ${if(requestor?.username == user?.username) {return "yourself";} else {return user.firstname+' '+user.lastname+'-'+user?.username;}} for Planning Cloud with Request ID - ${requestid} has been rejected.<br><br>Rejected By -${allRejectors.collect{it.username}.join(',')}<br>Request rejection comment -${def r=allRejectors.collect{it.username}.join(',').toString();r=r.replaceAll("[, ;]","");def ec=accessItems.collect{it.comments}.join(',').toString();def rc=ec.substring(ec.lastIndexOf(r+")] ")+(r+")] ").length());return rc;}<br><br>Regards<br> <br><br></div><img alt="" src="">

Let's say the comments are:

[01/19/23 15:39:21 UTC -Ram Singh (ABCD)] sqdwewdew
[Jan 19, 2023 15:40:48 UTC - Shyam Singh(CDER)] reject1

From the above example, I just want to fetch the rejection comment which is: "reject1".

So, what I am trying to do is ..since the rejector's username+")] " will be present only once in the entire comment, I am fetching the last index 0f "CDER)] ". Because, after that we will just have the rejection comment by this user(rejector).

 

xurde

AS5278
Regular Contributor II
Regular Contributor II

The below code worked for me. But it works only if the workflow is a serial workflow i.e it ends whenever any rejector rejects a request.

Request Rejection Comment - ${accessItems.collect{it.comments}.join(',').toString().substring(accessItems.collect{it.comments}.join(',').toString().lastIndexOf(allRejectors.collect{it.username}.join(',').toString().trim()+')] ')+(allRejectors.collect{it.username}.join(',').toString().trim()+')] ').length())}

xurde

So you requirement is fulfilled ?


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

AS5278
Regular Contributor II
Regular Contributor II

For now..yes

xurde