- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 11:40 PM
Before a record is inserted into the sc_req_item table, a business rule is made to run: if the cat_item field matches a certain condition, the approval in the record of the parent request (sc_request table) that is in the request field I want to update the field. However, this does not work, perhaps because of asynchronous communication. How can I achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:05 AM
Hi @SotaT
is the BR is on the sc_req_item table?
make it a after or Async insert BR
(function executeRule(current, previous /*null when async*/ ) {
var propValue = gs.getProperty('〇〇'); //〇〇 is this a correct property name?
if (propValue.includes(current.getValue('cat_item'))) {
var reqGR = current.request.getRefRecord();
if (reqGR.isValidRecord()) {
reqGR.setValue('approval', 'approved');
reqGR.update();
}
}
})(current, previous);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:01 AM
try this, I updated the script and added logs
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:05 AM
Hi @SotaT
is the BR is on the sc_req_item table?
make it a after or Async insert BR
(function executeRule(current, previous /*null when async*/ ) {
var propValue = gs.getProperty('〇〇'); //〇〇 is this a correct property name?
if (propValue.includes(current.getValue('cat_item'))) {
var reqGR = current.request.getRefRecord();
if (reqGR.isValidRecord()) {
reqGR.setValue('approval', 'approved');
reqGR.update();
}
}
})(current, previous);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 12:31 AM