How to print date using email script in notification based on employment date for below condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:04 AM - edited ‎10-06-2022 03:07 AM
Condition= Employment start Date + 30 days + The 1st of the next month. Ex.- Employment start Date=10 Sept +30 = 10 October so I want to print 1 November using an email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:24 AM
Hi @Adi13 ,
Try below code for adding days:
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(30);
current.datefield = gdt;
Note: add Days() is a deprecated method so try using addDaysLocalTime().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:28 AM
you always want to add 30 days or 31 days?
what script did you try so far?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:44 AM
Always want to add 30 days and after added want to print 1 day of next month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 03:43 AM
var empDate = employment_start_date.getValue();
var returnDate = new GlideDateTime(empDate);
returnDate.addDays(30);
var gdt = returnDate.getDate();
gdt.addMonths(1);
var gd = new GlideDate();
gd.setValue(gdt.toString());
template.print(gd.getByFormat("MM-1-yyyy"));