- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:16 AM
I am trying to write a Business Rule to update the sysapproval_group short_description field with the content of the RITM (sc_req_item) short_description. Below is the code I'm working with currently. I get an error in the log file when this BR fires:
Invalid query detected, please check logs for details [Unknown field null in table sc_req_item]
Business Rule:
Table: sysapproval_group
After Insert or Update
No Filter conditions specified
Advanced is checked
Script:
(function executeRule(current, previous /*null when async*/) {
// Get the Request Item (RITM) sys_id
// var ritmSysId = current.request_item.toString();
var ritmSysId = current.request_item();
// Check if the Request Item field is not empty
if (ritmSysId) {
// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
// Update the Group Approval short description with the RITM short description
// current.short_description = ritmGr.short_description.toString();
current.short_description = ritmGr.short_description();
}
}
})(current, previous);
Why would I get the error? Any advice?
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:40 AM
Hi @Joe Trimble ,
I tried your problem in my PDI and it works for me please make some small configurations it will work for you
1. Please mark your BR Before not after.
2. Please add below code
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
gs.log('inside Check BR = ' + current.parent);
var ritmSysId = current.parent;
// Check if the Request Item field is not empty
if (ritmSysId) {
gs.log('inside IF = ' + current.parent);
// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
gs.log('inside IF and IF = ' + ritmGr.short_description);
// current.short_description = ritmGr.short_description();
current.setValue('short_description', ritmGr.short_description);
}
}
})(current, previous);
This will work for you
Here's the result
Short Description is updating in sysapproval_group table
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:40 AM
Hi @Joe Trimble ,
I tried your problem in my PDI and it works for me please make some small configurations it will work for you
1. Please mark your BR Before not after.
2. Please add below code
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
gs.log('inside Check BR = ' + current.parent);
var ritmSysId = current.parent;
// Check if the Request Item field is not empty
if (ritmSysId) {
gs.log('inside IF = ' + current.parent);
// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
gs.log('inside IF and IF = ' + ritmGr.short_description);
// current.short_description = ritmGr.short_description();
current.setValue('short_description', ritmGr.short_description);
}
}
})(current, previous);
This will work for you
Here's the result
Short Description is updating in sysapproval_group table
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 11:24 AM
Thank you! This does work. Appreciate the quick response!
Joe

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:09 AM - edited 04-22-2024 10:12 AM
@Joe Trimble You need to update the business rule to run before insert/update and keep the script as follows.
(function executeRule(current, previous /*null when async*/) {
// Get the Request Item (RITM) sys_id
var ritmSysId = current.parent+'';
// Check if the Request Item field is not empty
if (ritmSysId) {
// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
// Update the Group Approval short description with the RITM short description
current.short_description = ritmGr.getValue('short_description');
}
}
})(current, previous);
In case you do not wish to have an onBefore business rule and would like to just keep the business rule to run after insert/update then update the BR script as follows.
(function executeRule(current, previous /*null when async*/) {
// Get the Request Item (RITM) sys_id
var ritmSysId = current.parent+'';
// Check if the Request Item field is not empty
if (ritmSysId) {
// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
// Update the Group Approval short description with the RITM short description
current.short_description = ritmGr.getValue('short_description');
current.setWorkflow(false);
current.update();
}
}
})(current, previous);