- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 07:00 AM
GlideQuery seems to have a bug: when I have a table with a reference field to cmdb_ci and I want to do the following:
var sbf_object = new global.GlideQuery("x_some_table")
.get(sys_id, ["cmdb_ci.assigned_to.name", ""cmdb_ci.assigned_to.mail"])
.get();
it will throw an error if assigned_to is null.
The error message itself seems weird:
Cannot set property "name" of undefined to "Test User".
Will this be fixed or is it not intended to do Dot-Walking over two levels?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 01:07 AM
Thank you for the reply!
The .get() at the end executes the query and returns me the object.
The " sneaked in and the e got dropped but that was not the problem.
After some further debuging I managed to find the solution:
The problem itself was somewhere else so when I broke down the example it actually got lost.
Here the "working" error:
var object = new global.GlideQuery("x_some_table")
.get(sys_id, ["cmdb_ci.assigned_to", "cmdb_ci.assigned_to.name"])
.get();
The list of fields was very long, so I missed that at some point the value of the reference field and some values of the reference were added inside the field list.
This apparently causes this strange error message, which once you understand the cause makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 02:38 PM
Hi, I see a couple of syntax issues with your code
extra " before cmdb_ci.assigned_to.mail
mail is not a valid field for the referenced table (sys_user) and I suspect it should be cmdb_ci.assigned_to.email
.get(); is not required at end of the query.
This is tested and working in a PDI background window
//INC0000025
var sbf_object = new global.GlideQuery("incident")
.get('46f09e75a9fe198100f4ffd8d366d17b', ["cmdb_ci.assigned_to.name", "cmdb_ci.assigned_to.email"]);
gs.info(JSON.stringify(sbf_object, null, 2));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 01:07 AM
Thank you for the reply!
The .get() at the end executes the query and returns me the object.
The " sneaked in and the e got dropped but that was not the problem.
After some further debuging I managed to find the solution:
The problem itself was somewhere else so when I broke down the example it actually got lost.
Here the "working" error:
var object = new global.GlideQuery("x_some_table")
.get(sys_id, ["cmdb_ci.assigned_to", "cmdb_ci.assigned_to.name"])
.get();
The list of fields was very long, so I missed that at some point the value of the reference field and some values of the reference were added inside the field list.
This apparently causes this strange error message, which once you understand the cause makes sense.