Seiji_Moriyama

CA Tuesday Tip: Email Notifications in local time

Discussion created by Seiji_Moriyama Employee on Jun 15, 2011
Latest reply on Aug 1, 2014 by Seiji_Moriyama
[color=#ff0000]CA Access Control Tuesday Tip by Seiji Moriyama, Principal Support Engineer for 6/15/2011:[color]

CA Access Control Enterprise Management generates email notifications from email templates. Some of them contain date and time in their body. The date and time appear as UTC/GMT by default when an email is generated from one of the templates. Instead of asking end users to calculate by themselves, you can convert UTC/GMT to server's local time by using Javascript in the email templates.

For example, an email is sent to the requester when their Privileged Account Request is approved. It is generated from CreatePrivilegedAccountExceptionEvent.tmpl and the date and time are shown in UTC/GMT in it for "The permission is valid until:" field.
For showing local time, you can modify the template as below:

Original
<br> The permission is valid until: <b><%=_eventContextInformation.getSecondaryObjectAttribute("VALID_UNTIL", "")%> GMT</b>
Modified
<br> The permission is valid until: <b> <% var vu = _eventContextInformation.getSecondaryObjectAttribute("VALID_UNTIL", "");    var d = new Date;    d.setUTCDate(parseInt(vu.substr(0,2),10));    d.setUTCMonth(parseInt(vu.substr(3,2),10)-1);    d.setUTCFullYear(parseInt(vu.substr(6,4),10));    d.setUTCHours(parseInt(vu.substr(11,2),10));    d.setUTCMinutes(parseInt(vu.substr(14,2),10));    d.setUTCSeconds(parseInt(vu.substr(17,2),10)); %> <%= vu %> GMT<br> In local time: <%= d.toLocaleString()%></b>
After modifying the template, the second line is added in generated emails as shown below:
The permission is valid until: 16/06/2011 06:49:00 GMT In local time: June 16, 2011 3:49:00 PM GMT+09:00 
Please refer to CA Access Control Premium Edition Enterprise Administration Guide - Email Notifications section in Chaptor 2: Administoring CA Access Control Enterprise Management.

Outcomes