- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 09:00 PM
Hi Experts,
I dont know what is being refer here. Please see below code and help me to understand why logs are showing such error ?
(function executeRule(current, previous /*null when async*/ ) {
var reqitm = new GlideRecord('sc_req_item');
reqitm.addQuery('reqitm.number', current.document_id);
gs.log('After addquery');
reqitm.addQuery();
while (reqitm.next()) {
gs.log('Inside while');
reqitm.watch_list = current.u_reviewer;
reqitm.watch_list.update();
}
})(current, previous);
Log Statement: Invalid query detected, please check logs for details [Unknown field undefined in table sc_req_item]
Note: Business rule is written on sysapproval_approver table.
Any help would be appreciated.
Thanks
Bishal
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 09:08 PM
Hi,
some changes
1) you used wrong field in query
2) you should use query() and not addQuery() if you wish to query
3) while updating
(function executeRule(current, previous /*null when async*/ ) {
var reqitm = new GlideRecord('sc_req_item');
reqitm.addQuery('sys_id', current.document_id);
reqitm.query();
if (reqitm.next()) {
reqitm.watch_list = current.u_reviewer.toString();
reqitm.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 09:16 PM
Hi Maik,
But object.number is the correct way to access any field in the form right. Why this an exception here in sc_req_item table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 09:42 PM
Hi
please make yourself familiar with the concept of Sys IDs:
- https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/table-admi...
- https://community.servicenow.com/community?id=community_article&sys_id=a3174522db3b7810a538826305961...
"number" is just a field with a kind of counter. And such field is unique identifier and also not available for all tables.
Kind regards
Maik