- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 08:59 AM
I have 2 datetime fields and also have a duration (single line of text). I am trying to compute the difference between the start and end date and put the difference in the duration field.
I am having a difficult time figuring this out via client script, this is on a service catalog item. I tried to use the "gs" api, but it frowns upon that in client scripts. I then tried this and still no luck:
var startDate = g_form.getValue("start_date");
var endDate = g_form.getValue("end_date");
alert(startDate + " ," + endDate);
var dc = new DurationCalculator();
var dur = dc.calcScheduleDuration(startDate, endDate);
alert(dur);
Any advice?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 09:37 AM
Hi Josh
Methods of duration calculator can be used only on the server side. Make an Ajax call and use this method in script include.
You can also use GlideSchedule for duration calculation.
Thanks
Abhinandan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 09:43 AM
This post might be helpful:
Client Script Date/Time Functions
I've used some of these functions, in conjunction with GlideAjax, to calculate date/time and populate a field (CI). Never done it for a cat item, but I have used GlideAjax calls on a cat item before successfully.
Apologies, should have read your post more thoroughly, wouldn't have suggested the 'gs' thing!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 09:37 AM
Hi Josh
Methods of duration calculator can be used only on the server side. Make an Ajax call and use this method in script include.
You can also use GlideSchedule for duration calculation.
Thanks
Abhinandan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2016 09:39 AM
Hi Josh
Don't forget to set Timezone & Schedule before using these methods. And Date/Time format also matters.
Thanks
Abhinandan