Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2018 07:50 PM
Hello Community,
Does anyone knows how to I convert seconds into GlideDuration object? I need the seconds to write to GlideDuration field type in a table.
The seconds are passed in by DurationCalculator object as below:
var dc = new DurationCalculator(); var duration = dc.calcScheduleDuration("2012-04-10 08:00:00","2012-04-14 06:00:00"));
I need the duration to be stored in GlideDuration object but can't seems to find the right way to do so.
Can anyone advise on this?
Thank you.
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2018 08:23 PM
var dc = new DurationCalculator();
var durationInSeconds = dc.calcScheduleDuration("2012-04-10 08:00:00","2012-04-14 06:00:00"); //Returns seconds
var durationInMs = durationInSeconds * 1000
var gDuration = new GlideDuration(durationInMs ); //Takes MS as paramater
current.setValue('your_duration_field', gDuration.getValue() ); //Set a duration field
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2018 08:23 PM
var dc = new DurationCalculator();
var durationInSeconds = dc.calcScheduleDuration("2012-04-10 08:00:00","2012-04-14 06:00:00"); //Returns seconds
var durationInMs = durationInSeconds * 1000
var gDuration = new GlideDuration(durationInMs ); //Takes MS as paramater
current.setValue('your_duration_field', gDuration.getValue() ); //Set a duration field
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2021 07:30 AM
Thank you Paul! 🙂 I reused a part of this solution. Really helpful!