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

Print the content of the analytics in the email body

kunal_saxena
Regular Contributor
Regular Contributor

Hi,

We have configured an email template for an analytics. We are trying to print the content of the analytics in the email body. For this, we had written the following in the email template:

<html>
	<head> 
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
	</head> 
	<body> 
	Hi,<br><br>Report - ${analyticsConfig.analyticsName} has been generated in Saviynt. Please find below the results:<br><br><table><tr><th>APPLICATION</th><th>NUMBER OF FAILED TASKS</th></tr><%int count=Integer.parseInt("${ANALYTICSDATA.APPLICATION.size()}"); for(int i=0;i<count;i=i+1){%><tr><td>${ANALYTICSDATA.'APPLICATION'[i]}</td><td>${ANALYTICSDATA.'NUMBER OF FAILED TASKS'[i]}</td></tr><%}%></table><br><br>Thank you,<br> <br>Identity and Access Management team<br>
	</body> 
</html>

However, when the analytics is executed, no email is sent out. Looking at the logs, I see the following error:

2024-04-03T20:45:55+05:30-ecm-worker--null-jcqkm--groovy.lang.MissingPropertyException: No such property: ANALYTICSDATA for class: SimpleTemplateScript155 at SimpleTemplateScript155.run(SimpleTemplateScript155.groovy:6) at com.saviynt.ecm.analytics.AnalyticsESService.notifyEmailToOwner(AnalyticsESService.groovy:2664) at com.saviynt.ecm.analytics.AnalyticsESService.emailAction(AnalyticsESService.groovy:16560) at com.saviynt.ecm.analytics.AnalyticsESService.doFileArchivalAndSendEmail(AnalyticsESService.groovy:14733) at com.saviynt.ecm.analytics.AnalyticsESService$_runControl_closure210_closure319.doCall(AnalyticsESService.groovy:14566) at com.saviynt.ecm.analytics.AnalyticsESService$_runControl_closure210.doCall(AnalyticsESService.groovy:14565) at java.lang.Thread.run(Thread.java:750)

Is there a way we can access the content of the analytics in the email template?

Thanks,
Kunal

9 REPLIES 9

PremMahadikar
All-Star
All-Star

Hi @kunal_saxena ,

Email attributes used here is wrong. Use ANALYTICDATAMAP.

  • ${ANALYTICSDATAMAP.'APPLICATION'[i]}
  • ${ANALYTICSDATAMAP.'NUMBER OF FAILED TASKS'[i]}.

Can you try below email body,

 

 

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	</head>
	<body>
		Hi,
		<br>
		<br>
		Report - ${analyticsConfig.analyticsName} has been generated in Saviynt.
		Please find below the results:
		<br>
		<br>
		<table>
			<tr>
				<th>
					APPLICATION
				</th>
				<th>
					NUMBER OF FAILED TASKS
				</th>
			</tr>
			<%int count=Integer.parseInt( "${ANALYTICSDATA.APPLICATION.size()}");for(int i=0;i<count;i=i+1){%>
				<tr><td>
						${ANALYTICSDATAMAP.'APPLICATION'[i]}
					</td>
					<td>
						${ANALYTICSDATAMAP.'NUMBER OF FAILED TASKS'[i]}
					</td></tr><%}%>
		</table>
		<br>
		<br>
		Thank you,
		<br>
		<br>
		Identity and Access Management team
		<br>
	</body>

</html>

 

 

If this answers your questions, please consider selecting Accept As Solution and hit Kudos

Raghu
All-Star
All-Star

@kunal_saxena 

Reference Working query and script Sample :

Sample Query :

select u.username, u.username as 'UserUsername',u.displayname as 'Displaynameee',u.EMPLOYEETYPE,u.companyname,DATE_FORMAT(u.startdate,'%Y-%m-%d') AS 'Startdte',DATE_FORMAT(u.enddate,'%Y-%m-%d') AS 'enddte',u.departmentname,u.country,um.username as 'MUsername',um.email as 'ManagerEmail' from users u , users um where u.manager=um.userkey and u.statuskey=1 and DATE_FORMAT(u.enddate,'%Y-%m-%d') = DATE_ADD(CURRENT_DATE(),INTERVAL +3 DAY)


html code:

<html>
<table style="background-color: #eeeeee;margin-left: auto;margin-right: auto;">
<tbody>
<tr>
<td style="background-color: #eeeeee;">
<table width="80%" align="center">
<tbody>
<tr>
<td style="height: 3px; background-color: #eeeeee;"></td>
</tr>
<tr>
<td style="color: white; font-size: 24px;padding-top: 30px; padding-left: 24px; height: 130px;" bgcolor="#006050" width="10%">
<p style="font-family:Verdana; font-size: 30px; margin: 0px;padding-top: 20px"> <strong>Company logo <strong></p>
<p style="font-family:arial;color: #ffffff;font-size: 15px;"> Guest Account Expiry Notification
<p style="font-family:arial;color: #00cccc;font-size: 15px;margin-top: -1em"><br>Action Required by Manager</p>
<br/>
</td>
</tr>
<tr>
<td style="height: 8px; background-color: #eeeeee;"></td>
</tr>
<tr>
<td style="padding: 20px; font-size: 14px;" bgcolor="white">
<p style="font-family:arial">
Hi Account responsible person, <br><br> This is a reminder that the Guest Account below that reports to you is going to expire after 3 days.<br>
<tr> <td style="font-family:arial;padding: 20px; font-size: 14px;" bgcolor="white"><hr color="#006050"> <p style="font-family:arial;color: #006050;font-size: 15px;"><b><u>Account Details:</u></b> <br><br> <table border="1" align="center" > <tr > <th style="background-color:#006050;color: #ffffff">&nbsp&nbsp Account Name &nbsp&nbsp</th><td> &nbsp&nbsp${ANALYTICSDATA.'UserUsername'[0]}&nbsp&nbsp</td></tr> <tr><th style="background-color:#006050;color: #ffffff">&nbsp&nbsp Display Name &nbsp&nbsp</th><td>&nbsp&nbsp${ANALYTICSDATA.'Displaynameee'[0]}&nbsp&nbsp</td></tr> <tr><th style="background-color:#006050;color: #ffffff">&nbsp&nbsp Account Expiry date &nbsp&nbsp</th><td>&nbsp&nbsp${ANALYTICSDATA.'enddte'[0]} &nbsp&nbsp</td></tr><tr> <th style="background-color:#006050;color: #ffffff">&nbsp&nbsp Account Expires in days &nbsp&nbsp</th> <td>&nbsp&nbsp 3&nbsp&nbsp</td></tr> <tr></table> <p /> <br> <hr color="#006050"> <p style="font-family:arial;color: #006050;font-size: 15px;"><p style="font-family:arial;color: #006050;font-size: 15px;"> </td> </tr>
<td style="color: white; font-size: 24px; padding-left: 5px; height: 35px;" bgcolor="#A8A9AB" width="25%"/>
<p style="font-family:Verdana; font-size: 10px; margin: 0px;padding: 10px"><strong>©Company logo 2024</strong></p>
<tr> </tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</html>


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

rushikeshvartak
All-Star
All-Star

Make sure below config is enabled in global config.

rushikeshvartak_0-1712199282537.png

You can validate variable exposed in email template using below script

To get what variables are present to use in the email template, check using the below expression. By putting it in the email body, it will print all variable names with values, and then accordingly, you can use it:


${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'.

kunal_saxena
Regular Contributor
Regular Contributor

Thank you everyone for the prompt response.

@PremMahadikar - I tried the email template suggested by you. However, it gives similar MissingPropertyException for ANALYTICSDATAMAP property as it was throwing for ANALYTICSDATA:

2024-04-04T13:54:03+05:30-ecm-worker--null-jcqkm--groovy.lang.MissingPropertyException: No such property: ANALYTICSDATAMAP for class: SimpleTemplateScript297 at SimpleTemplateScript297.run(SimpleTemplateScript297.groovy:24) at com.saviynt.ecm.analytics.AnalyticsESService.notifyEmailToOwner(AnalyticsESService.groovy:2664) at com.saviynt.ecm.analytics.AnalyticsESService.emailAction(AnalyticsESService.groovy:16560) at com.saviynt.ecm.analytics.AnalyticsESService.doFileArchivalAndSendEmail(AnalyticsESService.groovy:14733) at com.saviynt.ecm.analytics.AnalyticsESService$_runControl_closure210_closure319.doCall(AnalyticsESService.groovy:14566) at com.saviynt.ecm.analytics.AnalyticsESService$_runControl_closure210.doCall(AnalyticsESService.groovy:14565) at java.lang.Thread.run(Thread.java:750)

@Raghu - ANALYTICSDATA is throwing the MissingPropertyException exception.

@rushikeshvartak - I set the property as suggested by you in Global Config. Also, I printed the variables available in the email template. Below are the variables:

date = 2024-04-02 15:18:09
endpoint = null
totalRecords = 2
analyticsConfig = com.saviynt.ecm.analytics.AnalyticsConfigES : 1543
endpointDisplayName = null
baseUrlForEmail = https://abc.saviyntcloud.com/ECM
ownerEmail =
out = java.io.PrintWriter@6c381b38

It does not have ANALYTICSDATA or ANALYTICSDATAMAP variable exposed.

Is there any other way to print the content of the analytics in email body?

Thanks,

Kunal

Please follow below article 

https://forums.saviynt.com/t5/identity-governance/analyticsdata-and-analyticsdatamap-are-not-working...

and can you share your analytics query ?


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

kunal_saxena
Regular Contributor
Regular Contributor

@Raghu - Thanks for the reply. Looking at the forums post that you shared, it seems the ANALYTICSDATA variable is available when we add users.username to the query.

However, in this case, the requirement is to send an email to an operations team. The email should contain the summary of the failed tasks, i.e., the count of failed tasks grouped by endpoint. Therefore, we have created the following query:

SELECT
	ENDPOINT.ENDPOINTNAME AS 'APPLICATION',
	count(*) as 'NUMBER OF FAILED TASKS'
FROM 
	ARSTASKS TASKS, 
	USERS USERS, 
	ENDPOINTS ENDPOINT 
WHERE 
	TASKS.USERKEY = USERS.USERKEY 
	AND TASKS.ENDPOINT = ENDPOINT.ENDPOINTKEY 
	AND TASKS.PROVISIONINGTRIES IS NOT NULL 
	AND TASKS.PROVISIONINGTRIES >= 1 
	AND TASKS.STATUS NOT IN (3, 4, 9, 8)
	AND DATE(TASKS.TASKDATE) >= DATE(NOW() - INTERVAL ${lastNDays} DAY)
GROUP BY
	ENDPOINT.ENDPOINTNAME

The query returns the expected results. The challenge is how to display these results in email body without having users.username in the analytics query.

Thanks,

Kunal 

@kunal_saxena ,

PremMahadikar_0-1712245014223.png

If this answers your questions, please consider selecting Accept As Solution and hit Kudos

can you try below query

SELECT
USERS.USERNAME,
USERS.USERNAME AS 'GLOBAL ID',
ENDPOINT.ENDPOINTNAME AS 'APPLICATION',
count(*) as 'NUMBER OF FAILED TASKS'
FROM
ARSTASKS TASKS,
USERS USERS,
ENDPOINTS ENDPOINT
WHERE
TASKS.USERKEY = USERS.USERKEY
AND TASKS.ENDPOINT = ENDPOINT.ENDPOINTKEY
AND TASKS.PROVISIONINGTRIES IS NOT NULL
AND TASKS.PROVISIONINGTRIES >= 1
AND TASKS.STATUS NOT IN (3, 4, 9, 😎
AND DATE(TASKS.TASKDATE) >= DATE(NOW() - INTERVAL ${lastNDays} DAY)
GROUP BY
ENDPOINT.ENDPOINTNAME


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

SELECT
	'admin' as username,ENDPOINT.ENDPOINTNAME AS 'APPLICATION',
	count(*) as 'NUMBER OF FAILED TASKS'
FROM 
	ARSTASKS TASKS, 
	USERS USERS, 
	ENDPOINTS ENDPOINT 
WHERE 
	TASKS.USERKEY = USERS.USERKEY 
	AND TASKS.ENDPOINT = ENDPOINT.ENDPOINTKEY 
	AND TASKS.PROVISIONINGTRIES IS NOT NULL 
	AND TASKS.PROVISIONINGTRIES >= 1 
	AND TASKS.STATUS NOT IN (3, 4, 9, 8)
	AND DATE(TASKS.TASKDATE) >= DATE(NOW() - INTERVAL ${lastNDays} DAY)
GROUP BY
	ENDPOINT.ENDPOINTNAME

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