
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 06:31 AM
Hello. I created a business rule (after insert, global scope) in the sc_req_item table. This rule needs to get a GlideRecord in the sc_request table of the REQ record associated with the RITM being created.
var req = new GlideRecord("sc_request");
req.get(current.getValue("request"));
After that, data from the REQ is prepared in order to be sent to a REST integration.
However, the business rule is not able to get this GlideRecord. I use gs.info to verify if the req variable is getting the necessary record, but it returns null.
Does anyone know why this happen and if there is a way to fetch this REQ GlideRecord in the RITM Business Rule?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 06:46 AM
Hi Rafael,
I was seeing the same in my PDI after Insert. For some reason, changing it to the longer syntax seems to work:
function executeRule(current, previous /*null when async*/) {
var req = new GlideRecord("sc_request");
req.addQuery('request', current.request);
req.query();
if (req.next()) {
gs.addInfoMessage('number = ' + req.number)
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 06:46 AM
Hi Rafael,
I was seeing the same in my PDI after Insert. For some reason, changing it to the longer syntax seems to work:
function executeRule(current, previous /*null when async*/) {
var req = new GlideRecord("sc_request");
req.addQuery('request', current.request);
req.query();
if (req.next()) {
gs.addInfoMessage('number = ' + req.number)
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 06:48 AM
Hi ,
Seems there is already solution available here Servicenow importance of getValue and getDisplayValue method | ServiceNow getters | Servicenow Learn...
Also there is request field available in "RITM" table and you can access the same via current. Request.
Regards,
Luxo