Start the Timer(time_worked) field when the state changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all,
I want to start the Time field field when the state changes to In progress and want to pause it when it changes to on hold.
How to achieve this?
I have made glide.ui.timer.started - false, to stop it from starting automatically.
Thanks,
Poorva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Time work only runs when someone is actively looking at the form. It also only saves that data when the records is saved so I'm curious on why you want to stop and start time worked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @poorva1,
Good point from @Brian Lancaster , it's always good to start from "Why?", why you really need it, and if you can answer, it will also be helpful to me to suggest you right solution.
In the meantime, if you "just need it", you can create the onBefore Business Rule, for the right table, condition that "State is changed",
(function executeRule(current, previous /*null when async*/) {
// Start timer when state changes to In Progress
if (current.state == '2' && previous.state != '2') { // assuming '2' = In Progress
current.timer_start = true;
gs.eventQueue('timer.start', current, current.sys_id, current.state);
}
// Pause timer when state changes to On Hold
if (current.state == '3' && previous.state != '3') { // assuming '3' = On Hold
current.timer_pause = true;
gs.eventQueue('timer.pause', current, current.sys_id, current.state);
}
})(current, previous);
I hope it helps you. If yes, please mark my comment as helpful. Thank you!
Best regards,
Renat Akhmedov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks @Renat Akhmedov, I'll give this a try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @poorva1,
Please let me know about the result, and please don't forget to mark it as helpful if my answer helped you in a some way,
Best regards,
Renat Akhmedov
