current.update in Async business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 01:02 AM
i have total 40 async business rule. Those all business rules are in production. in those business rules we used the current.update() .Now the servicenow not alowing the current.update.
i want to replace the current.update and working thpose business rules properly.
What is the solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 01:41 AM
Hi @DWARAM REDDY ,
To mitigate this issue, Create Script Include to handle the business logic (currently in async BR) and call the script include in async BR, you can also pass current and previous objects to the Script Include method if needed.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 03:43 AM
Thanks for the Reply .
in that case 40 script include are needed for calling 40 Async business rules right? suppose if the current.update() not required in business rule that time can i use the AbortAction() .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 07:20 AM
I don't think abort action will do. Instead if you don't need current.update(), you can simply remove that line.
Regarding 40 script includes, you generalise the Script Inlcude to handle most common scenarios and reduce number of SIs required.
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 07:25 AM
Hi,
To replace the use of current.update(), you can use the gs.eventQueue API to queue an event that will update the record outside of the asynchronous Business Rule's execution context.
Here's an example of how you can replace the use of current.update() in an asynchronous Business Rule:
// Queue an event to update the current record
gs.eventQueue("record.update", current, current.getTableName(), current.sys_id);
In the above code, we use the gs.eventQueue API to queue an event of type "record.update" that will update the current record. The first argument is the type of event we want to queue, the second argument is the record we want to update, and the third and fourth arguments are the table name and sys_id of the record, respectively.
Note that the gs.eventQueue API is asynchronous, so the record will be updated outside of the asynchronous Business Rule's execution context. This means that you may not see the updated record immediately, but it will be updated eventually.
You will need to update all of your asynchronous Business Rules that use current.update() with this new code to avoid data inconsistency issues.
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar