Ding ding ding! Thanks for the update Mickey. Nobody ever pays attention to the order field until things get weird.



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Sagar V1
Mega Expert

Hi Cegon,



Avoid using current.update() in a business rule script. The update() method triggers business rules to run on the same table for insert and update operations, leading to a business rule calling itself over and over. Changes made in before business rules are automatically saved when all before business rules are complete, and after business rules are best used for updating related, not current, objects. When a recursive business rule is detected, the system stops it and logs the error in the system log. However, current.update() causes system performance issues and is never necessary.


You can prevent recursive business rules by using the setWorkflow() method with the false parameter. The combination of the update() and setWorkflow()methods is only recommended in special circumstances where the normal before and after guidelines mentioned above do not meet your requirements.



Thanks,


Sagar


davidpanson
Mega Expert

Just beating a dead horse now but to be explicit relating to your issue you can just remove current.update() to solve your problem. I tried it without and it functions fine the way you have it set up. (from my quick testing anyway) The current.update() will cause it to update again and create the duplicate in your log. In the best practices which has been quoted and referenced it says never to use current.update()



http://wiki.servicenow.com/index.php?title=Business_Rules_Best_Practices#gsc.tab=0


Hi David,



you can just remove current.update() to solve your problem. I tried it without and it functions fine the way you have it set up.


I'd love to see your test results and understand which BRs are triggering and in what order. Adding updates to current fields in an after or async rule without any update does not update those field values.


You are correct. I must have a duration calculation I can't find somewhere else. My mistake.