- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2021 11:47 PM
Hi,
How can i get the yesterday date in subject line and body text of Scheduled report ?
And also, is it possible to include specific DL's in CC of scheduled reports?
Please help me on this
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 04:47 AM
Hi,
this worked well for me
var gdt = new GlideDateTime();
gdt.addDaysUTC(-1);
var dt = new GlideDate();
dt.setValue(gdt.getDate());
gs.info('Actual date->' + dt);
var year = dt.getByFormat('YYYY');
var day = dt.getByFormat('dd');
var month = dt.getByFormat('MMMM');
var ordinal = dateOrdinal(day);
function dateOrdinal(d) {
return d+(31==d||21==d||1==d?"st":22==d||2==d?"nd":23==d||3==d?"rd":"th");
}
var finalStr = month + ' ' + ordinal + ' ' + year;
gs.info('Final date->' + finalStr);
Output:
[0:00:00.064] Script completed in scope global: script
Script execution history and recovery available here
*** Script: Actual date->2021-04-15
*** Script: Final date->April 15th 2021
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 12:57 AM
Hi
You can add a notification email script in the message body.
So you can take the advantage of all the objects available inside that.
//For yesterdays date
var gdt = new GlideDateTime();
gdt.add(-1);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 01:04 AM
Hi,
As mentioned you can include email script in email body
Adding to his point here is the email script
var gdt = new GlideDateTime();
gdt.addDaysUTC(-1);
template.print(gdt.getDate());
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 03:26 AM
Ankur, how can i get the date format like April 15th 2021?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 03:40 AM
Hi,
you need to do manipulation there
check this
https://stackoverflow.com/questions/15397372/javascript-new-date-ordinal-st-nd-rd-th
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader