How to calculate time spent on task.

Siva P
Tera Expert

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.

3 REPLIES 3

Ashutosh Munot1
Kilo Patron
Kilo Patron

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

Ash10Patil
Kilo Guru

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.

Hemant Goldar
Mega Sage

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