- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:40 AM
Hi All,
I have an after business rule that checks if the change request moved to 'Review' state and updates the current date in a field. Can anyone please correct the following script that I've written.
setReviewFields();
function setReviewFields() {
time = new GlideDateTime();
current.u_reviewed_at = time;
current.update();
}
Because of using current.update() I can see that the state transition from 'Implement' to 'Review' is happening twice, so I have decided to use setWorkflow(false) option to stop that. Is there any other way I can write this code? Is there any other way to do it without code?
Thanks,
Kevin
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:44 AM
Doing a current.update in an after BR is never a good idea.
Have you tried putting your code in a Before BR and just setting the order to something over 100k?
Also for your code you should be able to just do
current.setValue("u_reviewed_at", new GlideDateTime());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:44 AM
Doing a current.update in an after BR is never a good idea.
Have you tried putting your code in a Before BR and just setting the order to something over 100k?
Also for your code you should be able to just do
current.setValue("u_reviewed_at", new GlideDateTime());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 09:57 AM
No I haven't tried, I was fixing this old BR and was thinking if I could do without current.update() in the same after BR. Seems like I have to use update() for this setValue() as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 10:08 AM
You would need to call current.update if you do not move it to an onBefore rule with a very high order, which really is going to be only 1 of two ways to fix the double update. The other way to fix the double update is to make the BR run Asynchronous and leave in the current.update. I think the before update BR would be better.
As for the code I was just giving a different way to go about it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 05:50 AM
Thank you Drew !