How to add two duration fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2014 06:19 AM
Hi All,
On Incident page, we have Time Card entry tab. And on that there is Duration field which is getting calculated from two other fields as Start Time and End Time. Therefore suppose a single incident should have multiple Duration added. Now on incident there is Total Duration field where i would like the addition of all these Duration for Time Card entries. Can anyone please let me know how can i do it?
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2014 02:35 AM
ok so how is u_bc_time_entry related to incident, you may not be able to 'dot-walk' if it's not a field on incident, it's related another way, i.e. incident is the parent, then you will need to query for that record.
if they are seperate record on a table you would need to run GlideRecord query for those as well to add them to totalDur.
if you print out;
gs.addInfoMessage(current.u_bc_time_entry.u_hours_worked);
do you get anything, if no then this is not fetching that value because that dot-walk is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2014 06:20 AM
Hi G N,
You can use dateNumericValue() function which will convert duration back to seconds and will set it back to duration after adding another duration.
var dur = new DurationCalculator();
dur =gr.duration.dateNumericValue() + gr.duration.dateNumericValue();
gr.duration.setDateNumericValue(dur);
Hope this can help you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 10:19 AM
This worked for me! Thanks a ton!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2020 02:51 PM
If you have a while loop inside GlideRecord and I need to add the duration of each, how do you set the initial to 0 so you can add the first record? I tried setting something like dur =gr.duration.dateNumericValue() and it would not work.