Click HERE to see how Saviynt Intelligence is transforming the industry. |
04/12/2022 01:08 PM
Hi Team,
We are using Saviynt v5.5.
We want to show blank in email notification template , when the attribute is not filled.
for eg- while sending joiner notification, if location is not defined for the user, we need to send it as blank.
Currently its showing null.
Can anyone please guide how to achieve this.
Thanks,
Sitarasmi
Solved! Go to Solution.
04/12/2022 02:25 PM
Hi Sitarasmi,
You can use a simple code as below :
${null!=user.location?user.location:''}
Regards,
Adrien.
04/12/2022 02:25 PM
Hi Adrien,
I tried with this, but in this case, email itself is not getting triggered when the value is not given,
when removed, email is triggered.
Thanks,
Sitarasmi
04/12/2022 02:25 PM
Hi Sitarasmi,
Are you trying to send an email after submitting a Create User Request from UI that must go into approval ?
In this case, you might try something like this :
${accessItems.findAll{it.request_access_attrss.size()}.collect{it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('location')}.collect{it.attributeValue}}[0][0]}
If not, can you please let us know when exactly and how you would like to trigger your email ? This way we can give better insights.
Regards,
Adrien.
04/12/2022 02:25 PM
Hi Adrien,
We have configured end point level email notification for upon Active Directory New Account task completion
Once the user is created & Active Directory account is assigned, then we are triggering email.
Thanks,
Sitarasmi
04/12/2022 02:25 PM
Hi Adrien,
Please suggest how to handle null value in email templates
Thanks,
Sitarasmi
04/12/2022 02:25 PM
Hi Sitarasmi,
Can you please send the email template that you want to insert so I can give you proper insights on which attribute you want to handle null values ?
Thanks,
Adrien.
04/12/2022 02:25 PM
Hi Adrien,
PFB email template which we are using for joiner process.
User ID: ${user.systemUserName}
Employee ID: ${user.employeeid}
Start Date: ${user?.startdate.format("dd/MM/yyyy")}
User Name: ${user.firstname} ${user.lastname}
Email ID: ${user.email}
Line Manager: ${manager.firstname} ${manager.lastname}
Line Manager Email ID:${manager.email}
Contract Type: ${user.employeeType}
Business Unit: ${user.customproperty1}
Division: ${user.customproperty2}
Location:${user.location}
Role: ${user.customproperty4}
Here, Division & Role we are mapping with customproperties.Sometimes these values are blank & in email templates, we are getting null in that place.
Please guide how to resolve this.
Thanks,
Sitarasmi
04/12/2022 02:25 PM
Hi Sitarasmi,
If you want to display something else than null values, you can user below code for role and Division :
Division: ${null!=user.customproperty2?user.customproperty2:'Empty}
Role: ${null!=user.customproperty4?user.customproperty4:'Empty'}
Best,
Adrien.
04/12/2022 02:25 PM
Hi Adrien,
We want to display as blank only, instead of null or any other value.
Is there any way to achieve it ?
Thanks,
Sitarasmi
04/12/2022 02:25 PM
Hi Sitarasmi,
Just remove "Empty" in above code to have resulting code :
Division: ${null!=user.customproperty2?user.customproperty2:''}
Role: ${null!=user.customproperty4?user.customproperty4:''}
Regards,
Adrien
04/12/2022 02:26 PM
Hi Adrien,
I already tried with this, & email is not getting triggered if I am keeping this format.
Thanks.
Sitarasmi
04/12/2022 02:26 PM
Hi Sitarasmi.
On my own it does work fine.
Are you able to catch some logs to see the error that would explain why email is not triggered ?
Regards,
Adrien.
04/12/2022 02:26 PM
Hi Adrien,
We are getting parsing error in logs while using below format in email template. PFB logs.
Division: ${null!=user.customproperty2?user.customproperty2:''}
2021-02-08 10:37:15,962 [quartzScheduler_Worker-6] ERROR services.ArsTaskService - Error while sending email - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript6732.groovy: 1: unexpected token: > @ line 1, column 794.
2?user.customproperty2:''<span>}<br></sp
^
1 error
groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript6732.groovy: 1: unexpected token: > @ line 1, column 794.
2?user.customproperty2:''<span>}<br></sp
^
1 error
at com.saviynt.utility.TemplateUtilityService.getSimpleTemplateString(TemplateUtilityService.groovy:48)
at com.saviynt.utility.TemplateUtilityService.getTemplateString(TemplateUtilityService.groovy:29)
at com.saviynt.ecm.services.ArsTaskService$_sendTaskCompletionEmail_closure153_closure306_closure308.doCall(ArsTaskService.groovy:12406)
at com.saviynt.ecm.services.ArsTaskService$_sendTaskCompletionEmail_closure153_closure306.doCall(ArsTaskService.groovy:12218)
at com.saviynt.ecm.services.ArsTaskService$_sendTaskCompletionEmail_closure153.doCall(ArsTaskService.groovy:12143)
at com.saviynt.ecm.services.ArsTaskService.sendTaskCompletionEmail(ArsTaskService.groovy:12140)
at com.saviynt.ecm.services.ArsTaskService$_completeAutoProvTasks_closure138.doCall(ArsTaskService.groovy:8680)
at com.saviynt.ecm.services.ArsTaskService.completeAutoProvTasks(ArsTaskService.groovy:8662)
at WSRetryJob$_processupgradedmultithreadedtasks_closure18.doCall(WSRetryJob.groovy:982)
at WSRetryJob.processupgradedmultithreadedtasks(WSRetryJob.groovy:968)
at WSRetryJob.execute(WSRetryJob.groovy:486)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
2021-02-08 10:37:15,962 [quartzScheduler_Worker-6] DEBUG services.ArsTaskService - Error in sendTaskCompletionEmail :
groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript6732.groovy: 1: unexpected token: > @ line 1, column 794.
2?user.customproperty2:''<span>}<br></sp
^
1 error
04/12/2022 02:26 PM
Hi Sitarasmi,
From what I'm able to see, the code is wrongly written as you add <span> tag into, after having closed the single quotes where you want that empty value.
${null!=user.customproperty2?user.customproperty2:''<span>}....
Please try something like below instead, putting the <span> tag out of ${} data which is where you pass parameters, to fix your unexpected token exception (which is not a "feature" related issue, but more about how to properly write inside html code)
${null!=user.customproperty2?user.customproperty2:''}<span>....
Regards,
Adrien.
04/12/2022 02:26 PM
Hi Adrien,
Thanks a lot for figuring this out. It working now.
Regards,
Sitarasmi