After BR causing duplication of activity

Mickey_Cegon
Tera Expert

I created an After BR to calculate the calendar_duration on the rm_story table. I need to calculate the diff between the opened_at and closed_at fields, so I set it to run After Active changesTo False. Works great, but it shows up in the activity log once, with a second set of activity showing and a duplicate entry in the Audit History list.

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

I tried it as a Before BR, but it didn't work because the closed_at isn't populated yet.

Any suggestions would be helpful. Thanks in advance!

Mickey Cegon

Farm Bureau Financial Services, Inc.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

If you run this as an AFTER BR, it is going to trigger all the BRs again with the current.update().



If closed_at is not populated like you say, try doing a current.setWorkflow(false) right before and give your BR a very high order (10,000) so it runs last to avoid stopping other BRs that might run after it.



Reference:


Business Rules - ServiceNow Wiki


Business Rules Best Practices - ServiceNow Wiki  


View solution in original post

7 REPLIES 7

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.