Use current.update() ?

JK1
Giga Expert

Hey experts!

I know that you should never ever use current.update() on a business rule as it does a really nasty recursion. But is that so for the rest of the stuff? I've seen on UI action current.update() . Is that okay or its a bad practice ?

Cheers,

Joro

3 REPLIES 3

dvp
Mega Sage
Mega Sage

You must use current.update() in ui action to update the fields


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Georgi,



current.update() in UI actions is fine since you want the record to be updated with some new values in columns.


For business rule it should be avoided since business rule directly work on table and are designed to trigger and update the columns accordingly.


if you use current.update() in business rule then it may cause loop.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Patrick Schult2
Giga Guru

Current.update() is perfectly safe to use in any business rule that is not set to run Before - that is where the recursion will occur. Recursion is not a concern in UI actions or really other places besides a business rule.



If you are wanting to update the current record with a business rule, that's totally fine - you just need to run a Before Business Rule and not use current.update().



Read more about business rules and the order of operations here: https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/script/business-rules/reference...