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.

How to pull user details from userkey in Request Completion Email template

sk
All-Star
All-Star

Team,

We are trying to send notification to New Owner/Pre-Authrozied Users whenever they are added/removed for a FireFigther ID. We have a parameters(USEROWNERKEY, USEROWNERKEYREMOVED, PAMPREAUTHUSERSADDED, PAMPREAUTHUSERSREMOVED) which holds the key of added/removed user/s which may be single value or comma separated value. But how to get email, user details from that?

Below are parameters available while doing owner change: (Used this to get the details: ${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}})

ServiceAccountOwnerMap = [:]
entitlements = []
accessapprovers = com.saviynt.ecm.workflow.Access_Approvers : 2259076
USEROWNERKEYADDED = 23534
jbpm_activity_name = Manager_Approval_OwnerChange
allApproversComments = null
fullrowhtmltablerows =
listofallrolesinrequest = []
USERRANKJSON = {"23534":1}
entitlementshtmltablerowsv2 =
ACCOUNTKEY = 765844
ServiceAccountType =
requestlink = null/jbpmworkflowmanagement/showrequestdetails/SV_ServiceAccount_Workflow.1741183?reqid=2338
allRejectorsComments = null
rolesApprovedOrRejected = []
rolename =
request_access = com.saviynt.ecm.workflow.Request_Access : 4134
users = xxxxxxx
allRejectors = []
requestid = 1741183
USEROWNERKEY = 23534
rolemap = [:]
baseUrlForEmail = https://release-n-plus-one.saviyntcloud.com/ECM
ISPAMPROTECTEDACC = 0
assignee = xxxxxx
activityname = Manager_Approval_OwnerChange
ServiceAccountFlag = false
request = com.saviynt.ecm.workflow.ARS_Requests : 2338
ACCOUNTTYPE = FIREFIGHTERID
exceptionCount = 0
fullhtmlassignedrows =
requestkey = 1741183
roles = null
rejectedByMap = [:]
out = java.io.PrintWriter@128f3155
assigneemanager = xxxxx
endpoint = xxxxxxxxxxxxxxxxxxxxxxx
requesttype = Modify Account
dynamicAttrsList = []
approvallink = null/jbpmworkflowmanagement/showrequestdetails/SV_ServiceAccount_Workflow.1741183
allrolesinrequest =
email =
endpoints = (xxxxxxxxxxxxxxxxxxxxxxx)
entitlementshtmltablerows =
rolesshtmltablerows =
manager = xxxxxx
approvedByMap = [:]
ACCOUNTNAME = xxx-vaulting-11152022
Business_Justification =
USEROWNERKEYREMOVED = 15607
entitlement_values = []
allApprovers = []
requestor = xxxxx
BAP_ID = xxxx
ENDPOINT = 58
accounts = [[name:xxxvaulting-11152022, obj:xxx-vaulting-11152022]]
BAP_NAME = xxxxxxxxxxxxxxxxxxxxxx
user = xxxxxxx
curExecutionId = SV_ServiceAccount_Workflow.1741183
accessItems = [com.saviynt.ecm.workflow.Request_Access : 4134]

Below are parameters available while adding/removing Pre-Authorized Users:

entitlements = []
jbpm_activity_name = Grant_PreAuth_Changes
allApproversComments = null
PAMPREAUTHUSERSADDED = 15607,23534
fullrowhtmltablerows =
listofallrolesinrequest = []
USERRANKJSON = {"15607":1}
entitlementshtmltablerowsv2 =
ACCOUNTKEY = 765844
requestlink = null/jbpmworkflowmanagement/showrequestdetails/SV_ServiceAccount_Workflow.1770166?reqid=2361
allRejectorsComments = null
rolesApprovedOrRejected = []
rolename =
request_access = com.saviynt.ecm.workflow.Request_Access : 4157
users = xxxx
allRejectors = []
task = com.saviynt.ecm.task.ArsTasks : 30850
requestid = 1770166
USEROWNERKEY = 15607
rolemap = [:]
baseUrlForEmail = https://release-n-plus-one.saviyntcloud.com/ECM
ISPAMPROTECTEDACC = 1
assignee = admin
activityname = Grant_PreAuth_Changes
request = com.saviynt.ecm.workflow.ARS_Requests : 2361
ACCOUNTTYPE = FIREFIGHTERID
exceptionCount = 0
fullhtmlassignedrows =
requestkey = 1770166
roles = null
rejectedByMap = [:]
out = java.io.PrintWriter@ef59e12
assigneemanager = xxxxx
endpoint = xxxxxxxxxxxxx
requesttype = Modify Account
dynamicAttrsList = []
approvallink = null/jbpmworkflowmanagement/showrequestdetails/SV_ServiceAccount_Workflow.1770166
allrolesinrequest =
email =
endpoints = (xxxxxxxxxxxxx)
entitlementshtmltablerows =
rolesshtmltablerows =
manager = xxxxxx
approvedByMap = [:]
ACCOUNTNAME = xxxxx-vaulting-11152022
Business_Justification =
entitlement_values = []
allApprovers = []
requestor = xxxxxx
BAP_ID = xxxxx
ENDPOINT = 58
accounts = [[name:xxxxx-vaulting-11152022, obj:xxxxx-vaulting-11152022]]
BAP_NAME = xxxxxxxxxxxxxxxxxxx
user = xxxxx
curExecutionId = SV_ServiceAccount_Workflow.1770166
accessItems = [com.saviynt.ecm.workflow.Request_Access : 4157]

I have tried below variations none of them worked, Also we are using advanced HTML CSS format email templates

  • <br>${USEROWNERKEY}.collect{it.email
  • <br>com.saviynt.ecm.identitywarehouse.domain.Users.get(Long.valueOf(${accessItems.collect{ it.request_access_attrss.find{it.attributeName.toString().equalsIgnoreCase('USEROWNERKEY')}.collect{it.attributeValue}}.get(0)})).username
  • <br>${com.saviynt.ecm.identitywarehouse.domain.Users.get('${USEROWNERKEY}').email}
  • br>${com.saviynt.ecm.identitywarehouse.domain.Users.get(${USEROWNERKEY}).email
  • <br>${com.saviynt.ecm.identitywarehouse.domain.Users.get(Long.valueOf(${USEROWNERKEY}))?.email}
  • <br>${com.saviynt.ecm.identitywarehouse.domain.Users.get(Long.valueOf(${USEROWNERKEY})).email}
  • <br>${if(FIREFIGHTERID'.equals(task?.accountKey?.accounttype)){ def res = ''; task?.requestAccessKey?.collect{ it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('USEROWNERKEY')}.collect{it.attributeValue}.join('###')}?.get(0)?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res; } else{return user?.email}}

Below is the error I am seeing in logs:

2022-11-29T22:14:03-05:00-ecm-worker-"log":"groovy.lang.MissingMethodException: No signature of method: SimpleTemplateScript355.$() is applicable for argument types: (SimpleTemplateScript355$_run_closure1) values: [SimpleTemplateScript355$_run_closure1@1098dcde]\n","stream":"stdout","time":"2022-11-30T03:14:02.837083522Z"
2022-11-29T22:14:03-05:00-ecm-worker-"log":"Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)\n","stream":"stdout","time":"2022-11-30T03:14:02.837087564Z"


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

sk
All-Star
All-Star

@rushikeshvartak@amit_krishnajit@sahajranajee@avinashchhetri: any thoughts?


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

May be try the following

${com.saviynt.ecm.identitywarehouse.domain.Users.findById(USEROWNERKEY)?.username}
Thanks,
Amit

No luck @amit_krishnajit

I tried below statement in to address

${if('FIREFIGHTERID'.equals(task?.accountKey?.accounttype)){${com.saviynt.ecm.identitywarehouse.domain.Users.findById(USEROWNERKEY)?.email}} else{return user?.email}}

And below is the error:

2022-12-01T09:44:01-05:00-ecm-worker-"log":"2022-12-01 14:44:01,159 [quartzScheduler_Worker-9] DEBUG mail.EmailHistoryService - Template Created for Service Account Pre-Authorized User Changes Approved Notification to User##From\n","stream":"stdout","time":"2022-12-01T14:44:01.159538318Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"2022-12-01 14:44:01,198 [quartzScheduler_Worker-9] DEBUG mail.EmailHistoryService - Template Created for Service Account Pre-Authorized User Changes Approved Notification to User##to\n","stream":"stdout","time":"2022-12-01T14:44:01.199071998Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"2022-12-01 14:44:01,211 [quartzScheduler_Worker-9] ERROR mail.EmailHistoryService - Exception\n","stream":"stdout","time":"2022-12-01T14:44:01.212614227Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"groovy.lang.MissingMethodException: No signature of method: SimpleTemplateScript6711.$() is applicable for argument types: (SimpleTemplateScript6711$_run_closure1_closure2) values: [SimpleTemplateScript6711$_run_closure1_closure2@1e3365ea]\n","stream":"stdout","time":"2022-12-01T14:44:01.21264149Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"Possible solutions: is(java.lang.Object), run(), run(), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure)\n","stream":"stdout","time":"2022-12-01T14:44:01.212645288Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at SimpleTemplateScript6711$_run_closure1.doCall(SimpleTemplateScript6711.groovy:1)\n","stream":"stdout","time":"2022-12-01T14:44:01.212647833Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at SimpleTemplateScript6711.run(SimpleTemplateScript6711.groovy:1)\n","stream":"stdout","time":"2022-12-01T14:44:01.212650722Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at com.saviynt.mail.EmailHistoryService$_execute_closure17.doCall(EmailHistoryService.groovy:2188)\n","stream":"stdout","time":"2022-12-01T14:44:01.212653077Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at com.saviynt.mail.EmailHistoryService.execute(EmailHistoryService.groovy:1115)\n","stream":"stdout","time":"2022-12-01T14:44:01.212656067Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at EmailHistoryJob.execute(EmailHistoryJob.groovy:30)\n","stream":"stdout","time":"2022-12-01T14:44:01.212658208Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at org.quartz.core.JobRunShell.run(JobRunShell.java:199)\n","stream":"stdout","time":"2022-12-01T14:44:01.212660397Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"\u0009at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)\n","stream":"stdout","time":"2022-12-01T14:44:01.212662503Z"
2022-12-01T09:44:01-05:00-ecm-worker-"log":"2022-12-01 14:44:01,212 [quartzScheduler_Worker-9] DEBUG println.PrintlnToLogger - Println :: \u001b[1;31m| Error \u001b[22;39mgroovy.lang.MissingMethodException: No signature of method: SimpleTemplateScript6711.$() is applicable for argument types: (SimpleTemplateScript6711$_run_closure1_closure2) values: [SimpleTemplateScript6711$_run_closure1_closure2@1e3365ea]\n","stream":"stdout","time":"2022-12-01T14:44:01.212713508Z"

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

${if('FIREFIGHTERID'.equals(task?.accountKey?.accounttype)) print "${com.saviynt.ecm.identitywarehouse.domain.Users.findById(USEROWNERKEY)?.email}" else print "${user?.email}"}


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

@rushikeshvartak: Even that also giving error as below

2022-12-01T10:41:01-05:00-ecm-worker-"log":"2022-12-01 15:41:01,074 [quartzScheduler_Worker-8] DEBUG mail.EmailHistoryService - GOT THE TEMPLATE Service Account Pre-Authorized User Changes Approved Notification to User\n","stream":"stdout","time":"2022-12-01T15:41:01.074563885Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"2022-12-01 15:41:01,096 [quartzScheduler_Worker-8] DEBUG mail.EmailHistoryService - Template Created for Service Account Pre-Authorized User Changes Approved Notification to User##From\n","stream":"stdout","time":"2022-12-01T15:41:01.096622156Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"2022-12-01 15:41:01,098 [quartzScheduler_Worker-8] ERROR mail.EmailHistoryService - Exception \n","stream":"stdout","time":"2022-12-01T15:41:01.09866405Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"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:\n","stream":"stdout","time":"2022-12-01T15:41:01.098678729Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"SimpleTemplateScript6716.groovy: 1: unexpected token: ) @ line 1, column 204.\n","stream":"stdout","time":"2022-12-01T15:41:01.098681636Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":" e print \\\"${user?.email}\\\"}\"\"\");\n","stream":"stdout","time":"2022-12-01T15:41:01.098683965Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":" ^\n","stream":"stdout","time":"2022-12-01T15:41:01.09868684Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\n","stream":"stdout","time":"2022-12-01T15:41:01.098689355Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"1 error\n","stream":"stdout","time":"2022-12-01T15:41:01.098691301Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\n","stream":"stdout","time":"2022-12-01T15:41:01.09869333Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at com.saviynt.utility.TemplateUtilityService$_addTemplateCheck_closure1.doCall(TemplateUtilityService.groovy:238)\n","stream":"stdout","time":"2022-12-01T15:41:01.098695315Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at com.saviynt.mail.EmailHistoryService$_execute_closure17.doCall(EmailHistoryService.groovy:2183)\n","stream":"stdout","time":"2022-12-01T15:41:01.09869783Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at com.saviynt.mail.EmailHistoryService.execute(EmailHistoryService.groovy:1115)\n","stream":"stdout","time":"2022-12-01T15:41:01.098699962Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at EmailHistoryJob.execute(EmailHistoryJob.groovy:30)\n","stream":"stdout","time":"2022-12-01T15:41:01.098702067Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at org.quartz.core.JobRunShell.run(JobRunShell.java:199)\n","stream":"stdout","time":"2022-12-01T15:41:01.09870413Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"\u0009at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)\n","stream":"stdout","time":"2022-12-01T15:41:01.098706336Z"
2022-12-01T10:41:01-05:00-ecm-worker-"log":"2022-12-01 15:41:01,099 [quartzScheduler_Worker-8] DEBUG mail.EmailHistoryService - Total emails to be sent=0\n","stream":"stdout","time":"2022-12-01T15:41:01.099871102Z"


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

Print object separately in email body then prepare if else


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

Thank you guys @amit_krishnajit @rushikeshvartak for inputs

I can confirm that without if-else statement it is working with below statement

${com.saviynt.ecm.identitywarehouse.domain.Users.findById(PAMPREAUTHUSERSADDED)?.email}
So I modified my if-else statement in different format like this and it is working as expected
<% if (PAMPREAUTHUSERSADDED?.trim()) print "${com.saviynt.ecm.identitywarehouse.domain.Users.findById(PAMPREAUTHUSERSADDED)?.email}" %>
Can you guys please help me now if PAMPREAUTHUSERSADDED is having multi value with comma separated like below how to get emails of all users?
PAMPREAUTHUSERSADDED = 15607,23534

I am thinking of below statement will that work? If not please help me with right statement?

<% if (PAMPREAUTHUSERSADDED?.trim()) print "{{def res = ''; PAMPREAUTHUSERSADDED?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res;}" %>

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

I tested below statement it worked as expected.

<% if (PAMPREAUTHUSERSADDED?.trim()) print "${def res = ''; PAMPREAUTHUSERSADDED?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res;}" %>

Thanks guys for all your inputs which helped me to get to right statements


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

Guys one problem I found with above statement. Looks like PAMPREAUTHUSERSADDED, PAMPREAUTHUSERSREMOVED variable are available based on action taken. Let's say I didn't add pre-authorized users instead I removed then PAMPREAUTHUSERSADDED is not available in that case below statement is failing

<% if (PAMPREAUTHUSERSADDED?.trim()) print "${def res = ''; PAMPREAUTHUSERSADDED?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res;}" %>

So I need to change my if condition to check if that parameter exists or not, Can you guys help me with that? I tried below statement but somehow it is not working

<% if (task?.requestAccessKey?.collect{ it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('PAMPREAUTHUSERSADDED')}}) print "${def res = ''; PAMPREAUTHUSERSADDED?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res;}" %><% if (task?.requestAccessKey?.collect{ it.request_access_attrss.findAll{it.attributeName.toString().equalsIgnoreCase('PAMPREAUTHUSERSREMOVED')}}) print "${def res = ''; PAMPREAUTHUSERSREMOVED?.split(',')?.eachWithIndex{ num, idx -> res = res + com.saviynt.ecm.identitywarehouse.domain.Users.get(num)?.email + ',';}; return res;}" %>

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

sk
All-Star
All-Star

For now I have handled each action in workflow and triggering separate email notification based on action taken


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