- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
What is wrong in below script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
try this
var schedule = new GlideSchedule(inputs.schedule_sys_id);
var start = new GlideDateTime(inputs.starting_date);
var end = new GlideDateTime(inputs.ending_date);
var dur = schedule.duration(start, end);
outputs.duration = new GlideDuration(dur);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
The error "Invalid return type encountered" usually indicates the consumer of outputs.duration doesn't support the object being returned, rather than an issue with schedule.duration() itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Anukur solution worked, thanks @marianbruma for your efforts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi @Sathwik1
Refer these two posts:
https://www.servicenow.com/community/developer-forum/date-conversion-problems/m-p/1698988
var starting_date = new GlideDateTime(inputs.start_date);
var ending_date = new GlideDateTime(inputs.end_date);
var time_zone_adj = new GlideTime();
time_zone_adj.setValue("08:00:00");
starting_date.add(time_zone_adj);
ending_date.add(time_zone_adj);
var schedule = new GlideSchedule(inputs.schedule_sys_id);
var duration = schedule.duration(starting_date, ending_date);
//outputs.message = "Schedule Duration: " + duration.getDurationValue();
outputs.starting_date = starting_date;
outputs.ending_date = ending_date;
outputs.duration = duration;
Try both.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi @Sathwik1
Did you try the solution mentioned in the link.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti