Business Rule to set Actual Start Time when the Assigned to is set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 07:18 AM
I am looking for assistance on how to create a business rule that will populate the "Actual Start (work_start)" time with the current time when the "Assigned to (assigned_to)" field is populated for both a RITM and an INC. I would ideally like the work_start time to update if/when there is a change to the assigned_to field. I intend on using this to help me identify stale tasks that have not been updated since the actual work_start time. Please help if you have ideas or can assist with the process.
I will also need a fix-script to update all the records that have already been created.
Thank you in advance!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 07:22 AM
Hi @JP Marshall
You could try this:
(function executeRule(current, previous /* previous changes */) {
// Check if the Assigned to field has changed and is not empty
if (current.assigned_to.changes() && current.assigned_to) {
// Set the Actual Start field to the current time
current.work_start = new GlideDateTime();
current.work_start.update();
}
})(current, previous);
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 01:26 PM
@Shaqeel some pointers;
Never suggest to use a current.update in a business rule.
You risk ending up with a neverending loop.
The if statement in the script could instead be set as part of a condition filter, or condition on when to run the business rule, instead of being part of the script itself. That way the script is only run when needed.
Also, on a side note, best practice is to use current.setValue('field_name', 'value') instead of using dot-walked notation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 06:29 PM
So is the suggestion I used from Shaqeel not a great solution? If not, what would you suggest instead of this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2024 05:30 AM
I suggested to use a Flow instead of a business rule, because it's a no-code-solution that does the same thing.
If you still would want to go with the business rule solution, some minor tweaks would be in order (providing example below).
And you would still need to consider the scenario if you really want to reset the actual start value, if a record is first assigned, then emptied from assigned_to then assigned again.
Do note the additional condition I've added, to only execute if the Actual start value is empty, to prevent an overwrite of existing value.
Script for reference:
(function executeRule(current, previous /*null when async*/) {
current.setValue('work_start', new GlideDateTime());
})(current, previous);