
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2022 12:36 AM
Hello all,
I have a custom application, extended "task" table.
i need to get the task duration, like from record created to closed, taken how many day.
Refer to table below, there time data is all empty, how to make this available?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2022 12:46 AM
You can use metric definition on your custom table, You can refer to the OOTB Incident metric definition in the metric_definition table and modify the script accordingly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2022 12:57 AM
Hi Yandp,
You can solution this in 2 approaches.
1. Create an before update BR to execute when the state changes to Closed and use the below code
var create = new GlideDateTime(current.getValue('sys_created_on'));
var closed = new GlideDateTime(current.getValue('sys_closed_on));
var time = GlideDateTime.subtract(create,closed);
current.setValue('time_worked', time);
Do the appropriate formatting and converting the difference into days, hours etc. based on your requirement.
2. You can create a Metric definition that automatically calculates the duration between 2 specific states (Need to apply filters). Write a BR to copy this value to Time worked field.