How to calculate time spent on task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 11:28 PM
Hi,
I have two fields on my catalog task table(sc_task). Both are time fields.
1.Actual effort
2.Total Effort. i need to show total effort spent on that particular task.
For ex: When the user enter actual effort is 10 hours for this week the total effort it should show 10hours. later another user changed to 5 hours in actual effort then the total effort is 15 hours should show. How we can do this calculation.
Any help would be greatly appreciated.
thanks.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 12:00 AM
Hi,
I will write BR rule which is Before Update BR
Condition: Actual Effort Changes
Script:
current.u_total_effort = parseInt(current.u_actual_effort)+parseInt(current.u_total_effort);
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 12:02 AM
Hi,
You need to write business rule on sc_task table:
Condition: Before update, When Actual effort changes
Script:
var actual_effort = new GlideDateTime(current.<actual_effort>).getNumericValue();
var total_effort = new GlideDateTime(current.<total_effort>).getNumericValue();
total_effort = total_effort + actual_effort;
current.<total_effort> = new GlideDuration(total_effort);
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 12:20 AM
Hi Sambasiva,
You may find the below thread helpful.
https://community.servicenow.com/community?id=community_question&sys_id=aefcc369db9cdbc01dcaf3231f96...
I hope this helps!
Regards,
Hemant