- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 12:29 AM
Hi,
I want to update the same record in my table after it is inserted . So what is the best practice for updating same record in after insert business rule as current.update() might show recursive call in the health scan reports and without that it is not updating the record like it does for before insert br.
Regards,
Maharshi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 01:25 AM - edited 12-11-2024 01:27 AM
Hi @MaharshiC ,
In the rare case in which a current.update() cannot be avoided and must be used as no other method can be found to accomplish the update as needed, in order to prevent the recursion that can cause the performance issues, the current.update() should be used in conjunction with the setWorkflow(false) function. As an example, the following code snippet shows a very basic update to a record and use of the setWorkflow() function:
current.status = 1;
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
Refer below ServiceNow kb article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 01:25 AM - edited 12-11-2024 01:27 AM
Hi @MaharshiC ,
In the rare case in which a current.update() cannot be avoided and must be used as no other method can be found to accomplish the update as needed, in order to prevent the recursion that can cause the performance issues, the current.update() should be used in conjunction with the setWorkflow(false) function. As an example, the following code snippet shows a very basic update to a record and use of the setWorkflow() function:
current.status = 1;
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
Refer below ServiceNow kb article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand