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

Using dynamic attribute in email template

Dalalsaleh888
New Contributor
New Contributor

We have a requirement to print dynamic attribute in email template and found the below documentation/code for Configuring Service Account Creation Email template ${accessItems.collect{ it.request_access_attrss.find{it.attributeName.toString().equalsIgnoreCase('Location')}.collect{it.attributeValue}}.get(0) - Obtains a specific dynamic attribute name and value from request. But when we used this in the email template we got the below error : Error while sending email - No such property: accessItems for class: SimpleTemplateScript224 groovy.lang.MissingPropertyException: No such property: accessItems for class: SimpleTemplateScript224 at SimpleTemplateScript224.run(SimpleTemplateScript224.groovy:7) Could you please share the correct document or code to achieve the expected result . Saviynt document referred - https://docs.saviyntcloud.com/bundle/EIC-Admin-v23x/page/Content/Chapter06-EIC-Configurations/Creati...

23 REPLIES 23

rushikeshvartak
All-Star
All-Star

Which email template & where it is attached?


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

Dalalsaleh888
New Contributor
New Contributor

service account email template for new account creation.

${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}

 

find variables exposed using above script in email body


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

This expression didn't give the dynamic attribute. It gives variables of the account like name and owners and information about the requests.

Any other suggestions :)???

 

Share result 


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

${accessItems.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('Location')} .collect{it.attributeName.toString() + ': ' + it.attributeValue}.join('###')}.toString().replaceAll('\\[','').replaceAll('\\]','').replaceAll('\\,','')}


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

Result: no email received.

Error:

Dalalsaleh888_0-1688561711144.png

 

Share output of this email & when this email is triggered ? And where email template is attached ?


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

Hello,

As I mentioned, the email is not received due to the above-attached error. below is the email template:

Dalalsaleh888_0-1688562514736.png

 

I see you are trying to get accttype from access items. Is it custom Dynamic attribute if not try variable: ${ACCOUNTTYPE}


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

Yes, it is a custom Dynamic attribute name.

Then try below variable also make sure that Advanced CSS is enabled

${accessItems.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('accttype')}.collect{it.attributeValue}}.get(0)}


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

encountered the same previous error:

Dalalsaleh888_0-1688888922776.png

 

Manu269
All-Star
All-Star

Can you check this :

Favorite Food:<br>

${accessItems.collect{ it.request_access_attrss.find{it.attributeName.toString().equalsIgnoreCase('FavFood')}.collect{it.attributeValue}}.get(0)}<br><br>

Regards
Manish Kumar
If the response answered your query, please Accept As Solution and Kudos
.

Dalalsaleh888_1-1688890409473.pngDalalsaleh888_2-1688891074506.png

same error

Can you share output of below code 

${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}


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

Here is the result of ${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}

Dalalsaleh888_0-1688974733768.png

 

 

This looks like Task completion email not request approval emails. In that case accessItems won't work you need to derive from task .

Please use below in that case

${task?.requestAccessKey?.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('accttype')}.collect{it.attributeValue}}.get(0)}


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

This one worked! thanks. but, is there a way the value can be printed without the square brackets?

 

Dalalsaleh888_0-1689068607518.png

 

Try below options

 

${task?.requestAccessKey?.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('accttype')}.collect{it.attributeValue}}.get(0).join(', ')}

or

${task?.requestAccessKey?.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('accttype')}.collect{it.attributeValue}}.get(0).toString().replaceAll('\\[','').replaceAll(']','')}
or ${String.valueOf(task?.requestAccessKey?.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('accttype')}.collect{it.attributeValue}}.get(0)).replaceAll('\\[','').replaceAll(']','')}

 


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

Thank you! All 3 line codes print the dynamic attribute without [] 👍

Great can you mark it as solution so that it helps others as well


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