Scheduled job not picking up relevant records based on one small change to the filter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2025 02:07 AM
Hi, I was recently assigned to change the fitler criteria of a scheduled job. The filter was basically to look into table 1 and pick all the records which start with lbg- and put them into another table if they had been updated in the last 2 days, the requirement was to change that to pick records which contains lbg. So literally just an operator change. When I first did the change in dev it worked, but when the change moved to test it stopped working, now its not working in dev either.
Here is the code below as it was when I didn't change it:
//Review all records updated from last week from Network Nodes table
var grXBBCNN = new GlideRecord('x_btesi_bt_cmdb_network_nodes');
grXBBCNN.addEncodedQuery("u_ntn_managed_flag=Y^sys_updated_onRELATIVEGT@dayofweek@ago@2");
//grXBBCNN.addEncodedQuery("ntn_man_host_nameSTARTSWITHLBG-");
//grXBBCNN.setLimit(22);
grXBBCNN.query();
while (grXBBCNN.next()) {
//Initialize BT Network Node table
var grUCCBNN = new GlideRecord('u_cmdb_ci_bt_network_node');
//Get BT Product Type and Model Number from Port Node Product table
var grXBBCPNPT = new GlideRecord('x_btesi_bt_cmdb_port_node_products');
grXBBCPNPT.get(grXBBCNN.getValue('ntn_ndp_id'));
var btProductType = grXBBCPNPT.getElement('ndp_ndt_id.ndt_name').getValue() || '';
var modelNumber = grXBBCPNPT.getValue('ndp_name') || '';
... rest of script which picks the fields and does things
I literally only changed the line
Script execution error: Script Identifier: null.null.script, Error Description: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "value" is null, Script ES Level: 0
Couldn't decipher the stack trace resulting from the following JavaScriptException:
java.lang.NullPointerException: Cannot invoke "Object.toString()" because "value" is null: org.mozilla.javascript.JavaScriptException: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "value" is null: org.mozilla.javascript.Context.makeJavaScriptException(Context.java:2631) org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:2615) org.mozilla.javascript.MemberBox.invoke(MemberBox.java:243)
Can someone please tell me what's going on and why its not working at all anymore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2025 04:08 AM
@snow_beginner Try splitting or combining because LIKE is very commonly used and we all have been using it over the years successfully.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2025 01:44 AM
@snow_beginner Did this fix your issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2025 02:10 AM
Hi @RaghavSh
no it has not solved the issue, when I run it in background scripts, I get records, but they are undefined, even though I did name them. Here is what I ran in the backgroun scripts:
(function execute() {
var grXBBCNN = new GlideRecord('x_btesi_bt_cmdb_network_nodes');
gs.info("==== Records with CONTAINS LBG ====");
grXBBCNN.addQuery('u_ntn_managed_flag', 'Y');
grXBBCNN.addNotNullQuery('u_ntn_man_host_name');
grXBBCNN.addQuery('u_ntn_man_host_name', 'LIKE', '%LBG%');
grXBBCNN.addQuery('sys_updated_onRELATIVEGT@dayofweek@ago@2');
grXBBCNN.query();
while (grXBBCNN.next()) {
gs.info("Matched (CONTAINS): " + grXBBCNN.u_ntn_man_host_name);
}
})();
and here is what I got in return. It finds the few records which match the query, but they are undefined.
*** Script: ==== Records with CONTAINS LBG ====
*** Script: Matched (CONTAINS): undefined
*** Script: Matched (CONTAINS): undefined
*** Script: Matched (CONTAINS): undefined
*** Script: Matched (CONTAINS): undefined
*** Script: Matched (CONTAINS): undefined
*** Script: Matched (CONTAINS): undefined
