Cannot convert null to an object (scripts background)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2017 05:07 PM
Very simply put, I am running a query in scripts background and am getting the error 'cannot convert null to an object'. I'm not sure which piece is pulling back null. Can anyone advise what I can change in the script?
The logs say the error is in line 5. - 'org.mozilla.javascript.EcmaError: Cannot convert null to an object.'
var gr = new GlideRecord('x_access_request');
gr.query();
while (gr.next()){
if (gr.getValue('receivers').contains(gr.getValue('opened_by'))) {
gs.print('Number : ' + gr.number);
gs.print('Requestor : ' + gr.opened_by);
gs.print('Receivers : ' + gr.getValue('receivers'));
}
}
TIA!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2017 07:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2017 08:43 PM
Hi Robert,
Please check the value in the field Receivers. Check whether the field name is correct, whether it contains any value. What kind of field it is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 03:28 AM
I ended up thinking about this and getting it to work prior to reading these posts. It was receivers causing the issue because there were null values. I got both !includes and !contains to work. Thank you both for your replies!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 03:40 AM
Hi Robert,
It would be great if you close the thread so it doesnot appears in unanswered list.