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-07-2014 08:52 AM
Thanks, Mguy. I tried with first option and below is line of code:-
function onLoad() {
var totalDur =0;
var inc = new GlideRecord('task');
inc.addQuery('parent',current.parent.sys_id);
inc.query();
var count = inc.getRowCount();
gs.addInfoMessage('Count Of rows :' + count);
while(inc.next()) {
gs.addInfoMessage('Parent Sys Id :' + current.sys_id);
totalDur = totalDur + current.u_bc_time_entry.u_hours_worked;
gs.addInfoMessage('Total Duration :' + totalDur);
}
current.u_timediff =totalDur;
}
Task is parent.
Incident is child of task
and u_bc_time_entry are child records of task too under the reference of incident.
u_hours_worked is also Duration field and having the difference between two date tiem fields.
I am getting the correct incident sys id on time card. However totalDur is returning Nan and its showing blank on that Duration field. May i know where its wrong and what needs to correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2014 09:39 AM
Is u-bc-time_emtry a reference field on the current record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2014 09:27 PM
No, u_bc_time_entry is table and u_hous_worked, u_timediff are two duration fields. u_hours_worked showing the difference between Start & End date time fields. However, i wanted u_timediff to show the addition of all time entries under that Incident reference. Suppose if the first entry for incident INC00001 is been made through time card TM00001 was 01 DAY 01 hours 00 MM 00 SS (on u_hours_worked duration field it shown as 01 01 00 00 )and then second time card was entered with TM00002 and it has 00 DAY 00 hours 45 MM 00 SS (on u_hours_worked duration field it shown as 00 00 45 00) . Therefore, Total Duration (u_timediff field) will show the addition of these two time cards and it would be 01Day 01Hour 45MM 00SS). Along with that i have another query, how do i change duration to seconds value or in milliseconds?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2014 02:06 AM
this line here: current.u_bc_time_entry.u_hours_worked
is implying to the tool that u_bc_time_entry is a referencing field on the current incident that is referencing another table and record, is that the case?
duration is already a value in seconds in the DB, if you want to have a field that's displaying a number in seconds as opposed to hours, minutes, seconds etc then you should create an integer field. but at the back-end duration is a value in seconds, if you exported a list to excel with a duration field on it, you would see in Excel when you open it that it's an integer value.
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2014 02:22 AM
Yes, You are right.
u_bc_time_entry & incident both are extended from task table.