How can we check the record is met with the conditions of a table using sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 10:20 PM
Hi All,
I am having a requirement that when we pass the sys_id of a particular record like from this table "sysapproval_approver", it should fetch the sys_id of particular record in this table "sn_hr_sp_todos_config" only when condition met.
I tried code like this:
data.sysIdURL = $sp.getParameter("sys_id");
data.canRead = false;
data.tableName = $sp.getParameter("sysparm_tableName");
///for to-do sys_id///////
var scriptGR = new GlideRecord("sn_hr_sp_todos_config");
scriptGR.addActiveQuery();
scriptGR.addQuery('table', data.tableName);
scriptGR.query();
while (scriptGR.next()) {
var encodedQueryString = scriptGR.getValue("condition");
if (GlideFilter.checkRecord(data.sysId, encodedQueryString)) {
//gs.addInfoMessage(encodedQueryString.toString());
gs.addInfoMessage(scriptGR.getUniqueValue());
}
}
But it is not working, It is throwing Null Pointer exception. Please help me on working this with correct answer.
Thanks and Regards,
Allu Gopal.
- Labels:
-
Employee Service Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 10:55 PM
HI
Thanks and Regards,
Allu Gopal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 11:03 PM
Hi,
syntax is wrong
data.sysIdURL = $sp.getParameter("sys_id");
data.canRead = false;
data.tableName = $sp.getParameter("sysparm_tableName");
///for to-do sys_id///////
var scriptGR = new GlideRecord("sn_hr_sp_todos_config");
scriptGR.addActiveQuery();
scriptGR.addQuery('table', data.tableName);
scriptGR.query();
while (scriptGR.next()) {
var encodedQueryString = scriptGR.getValue("condition");
if (GlideFilter.checkRecord(scriptGR,encodedQueryString)) {
//gs.addInfoMessage(encodedQueryString.toString());
gs.addInfoMessage(scriptGR.getUniqueValue());
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader