- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 08:27 AM
Hi All,
Would really appreciate some help on this, probably very simple to those that know how.
Context:
I have a variable set that is auto populated by a 3rd party. the variable set is generic so has 2 different date fields.
Start_Date and End_Date, now both of these values are always populated. However the starter item is triggered when the new starter starts, and the leaver item is triggered when the End Date changes.
Both trigger the same notification.
This is an example and I have many more date fields on my use case, so I cant simply create a unique notification for each scenario. What I want to do is create a Mail script that I can add to my generic notification.
--------
I want the mail script to:
1. print the Start date if not empty and when the catalog item is for new starter
else
2. print the end date if field is not empty and when the catalog item is for a leaver
else
3. print nothing
The mail script that I have written so far gives me the date value correctly if the date variable is not empty but I am not sure how to do the rest..
-----------
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var Startdate = current.variables.EmployeeStartDate;
if (current.variables.EmployeeStartDate != '');
{
template.print("<p>Employee Start Date: </li>" + current.variables.EmployeeStartDate + "</p>");
}
})(current, template, email, email_action, event);
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 09:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 08:57 AM
Hi Mike,
so the eventual Script was as follows;
-----------
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var Item = current.cat_item;
var Startdate = current.variables.EmployeeStartDate;
var Enddate = current.variables.EmployeeEndDate;
if(Item == "cc7888e637419b4020a0532e53990e73" && Startdate != "")
{
template.print("<p>Employee Start Date: </li>" + Startdate + "</p>");
}
else if (Item == "3ff8886a37419b4020a0532e53990e3f" && Enddate != "")
{
template.print("<p>Employee End Date: </li>" + Enddate + "</p>");
}
})(current, template, email, email_action, event);
---
This works, however the date that is bought back is in the following format yyyy-mm-dd, and i need it to print in dd-mm-yyyy.
I have all the system preferences and user preferences set to the dd-mm-yyyy format still the email the i receive has the yyyy-mm-dd format.
How can i change this script so i can get the dd-mm-yyyy format please?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 09:03 AM
Add below and see if it comes in correct format.
var Startdate = current.variables.EmployeeStartDate.getDisplayValue();
var Enddate = current.variables.EmployeeEndDate.getDisplayValue();