06/18/2023 02:02 AM
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...
Solved! Go to Solution.
06/18/2023 02:31 AM
Which email template & where it is attached?
06/18/2023 03:34 AM
service account email template for new account creation.
06/18/2023 08:20 AM
${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
find variables exposed using above script in email body
06/21/2023 03:29 AM
This expression didn't give the dynamic attribute. It gives variables of the account like name and owners and information about the requests.
07/03/2023 06:32 AM
Any other suggestions :)???
07/03/2023 09:31 PM
Share result
07/03/2023 09:40 PM
${accessItems.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('Location')} .collect{it.attributeName.toString() + ': ' + it.attributeValue}.join('###')}.toString().replaceAll('\\[','').replaceAll('\\]','').replaceAll('\\,','')}
07/05/2023 05:55 AM
Result: no email received.
Error:
07/05/2023 06:05 AM
Share output of this email & when this email is triggered ? And where email template is attached ?
07/05/2023 06:09 AM
Hello,
As I mentioned, the email is not received due to the above-attached error. below is the email template:
07/05/2023 07:16 AM
I see you are trying to get accttype from access items. Is it custom Dynamic attribute if not try variable: ${ACCOUNTTYPE}
07/05/2023 07:18 AM
Yes, it is a custom Dynamic attribute name.
07/05/2023 07:53 AM
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)}
07/09/2023 12:48 AM
encountered the same previous error:
07/05/2023 07:28 AM
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>
07/09/2023 01:24 AM
same error
07/09/2023 07:26 AM
Can you share output of below code
${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
07/10/2023 12:39 AM
Here is the result of ${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
07/10/2023 10:55 AM
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)}
07/11/2023 02:43 AM
This one worked! thanks. but, is there a way the value can be printed without the square brackets?
07/11/2023 07:28 AM
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(']','')}
07/12/2023 01:36 AM
Thank you! All 3 line codes print the dynamic attribute without [] 👍
07/12/2023 07:15 AM
Great can you mark it as solution so that it helps others as well