How to calculate "Duration" for task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:08 PM
I want to calculate "duration" for task"
For incident, we can calculate "duration", but I can't calculate it for task, like this pic. (brank)
Please tell me why I can't calculate it for task and how to calculate it for task.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:12 PM
HI @hamar ,
I trust you are doing great.
Please refer below code for the same
(function executeRule(current) {
var startDate = current.getValue('start_date'); // Replace with your actual start date field
var endDate = current.getValue('end_date'); // Replace with your actual end date field
if (startDate && endDate) {
var durationInMillis = endDate - startDate;
var durationInSeconds = durationInMillis / 1000;
var durationInMinutes = durationInSeconds / 60;
current.setValue('duration', durationInMinutes);
}
})(current);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:22 PM
Thank you for your reply.
Sorry for being beginner, but I'd like to know where I should type this code.
I couldn't find.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:27 PM
Hi @hamar the reason for the not calcuating is that there is no Business rules configured for the task .Please find the OOB Business rules configured for calculating Duration.
You have to create similar kind of Business rule for the table where you need to auto populate duaration value by updating the conditions.
Cheers, hope that helps
Eswar Chappa
*** Please mark as "Correct" or "Helpful" as appropriate ***