- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 08:51 PM
Hello,
I have a date and time variable on the RITM that I need to check to see if it is empty or not.
I tried this code in email script, but it is not working: Thank you
if (current.variables.startDate.nil()) {
template.print('Date is invalid);
} else {
template.print('Date is valid);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 11:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2023 08:59 AM
Hi @JessicaM6884345
In mail script you already have the current object using which you can dot walk to RITM table, no need to do GlideRecord on RITM table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 10:02 PM
I am not sure email notification is on which table and email script is on which table but here is the syntax to check empty
If your email notification and email script is on RITM table then this should work fine
if (current.variables.startDate == '') {
template.print('Date is invalid);
} else {
template.print('Date is valid);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 10:30 PM
The notification is on sysapproval_approver table and email script is on sc_req_item table:
This is the correct syntax?
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var ritmGlide = new GlideRecord('sc_req_item');
ritmGlide.addQuery('sys_id', current.document_id.toString());
ritmGlide.query();
if (ritmGlide.next()) {
var date = ritmGlide.variables.select_end_date_time.getDisplayValue();
template.print('Date is valid');
} else {
template.print('Date is invalid');
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 11:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 11:19 PM
Hi @JessicaM6884345
You can try as below.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var date=current.sysapproval.variables.select_end_date_time.getDisplayValue();
var msg="Date is not valid"
if (date)
{
msg='Date is valid';
}
template.print(msg);
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2023 08:59 AM
Hi @JessicaM6884345
In mail script you already have the current object using which you can dot walk to RITM table, no need to do GlideRecord on RITM table.