The CreatorCon Call for Content is officially open! Get started here.

How to update a current field using ASYNC business rule

Roger9
Kilo Explorer

Hi ServiceNow community. I have a business rule with the following details below:

 

When to Run: async, Insert (checked)

I have a code which contains the following:

current.u_priority = '1';

My problem is it does not fill in the u_priority field (string) with the specified value ('1' in this case). 

I tried adding "current.update()" (without the double quote), it works but I observed that the BR was ran twice (I do not want the BR to run twice). Also, I researched that using an update() in any BR rule is not a best practice.

Appreciate if you can help me with my problem. Thank you.

 

4 REPLIES 4

Pedro Lopez
Kilo Guru

Hi Roger,

Just take in mind, Async BRs is like running the code in parallel. That is why you are seeing twice.

In this case, I am not sure if you can try After Insert or Before Insert. I don't know your requirements but let me know if both scenarios are useful for you.

 

Hope this helps,

Pedro Lopez

Roger9
Kilo Explorer

Hi Pedro,

 

Are you saying that updating a current field within an Async BR really does not work then?

We actually have a business requirement that require the BR to be in Async rule so we cannot opt to change it to BEFORE or AFTER. 

Rahamath
Tera Expert

Can you post  your complete requirement .or the screen shot of the existing BR

ScienceSoft
Tera Guru

Hi Roger,

It is not advised to use current.update within Business rule. It can lead to recursive business rules ( see Prevent recursive business rules )

If you need to update any field, you should use 'before' Business Rule. In case you have strong requirement to use 'ASYNC' BR, you may need to look for another approach/solution (e.g. call event from BR).