- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 11:50 PM
Hello Everyone,
I'm trying to query a table with a reference field with the following conditions:
var sysID = current.sys_id.toString();
var reqTask = new GlideRecord('u_request_tasks_definition');
reqTask.addQuery('u_order', '>', workflow.scratchpad.currentOrder);
reqTask.addQuery('u_associated_item.sys_id.toString()', sysID);
u_associated_item is the name of a column that is a reference to the sc_cat_item table. However when i try to make the condition the value returned from it is undefined. I also tried reqTask.u_associated_item, reqTask.u_associated_item.sys_id, reqTask.u_associated_item.toString() and so on but the value in the gs.log is every time Undefined. Any help will be greatly appreciated. Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 12:06 AM
var reqTask = new GlideRecord('u_request_tasks_definition');
reqTask.addQuery('u_order', '>', workflow.scratchpad.currentOrder);
reqTask.addQuery('u_associated_item.sys_id', current.cat_item.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 11:56 PM
Try This:
var sysID = current.sys_id;
var reqTask = new GlideRecord('u_request_tasks_definition');
reqTask.addQuery('u_order', '>', workflow.scratchpad.currentOrder);
reqTask.addQuery('sys_id', sysID);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 12:03 AM
Hello,
Thanks for the answer but it still does not work. What i need is to take the ID of the sc_cat_item that is referenced in the u_accosicated_item field and match it to the current.sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 12:12 AM
var sysID = current.sys_id.toString();
var reqTask = new GlideRecord('u_request_tasks_definition');
reqTask.addQuery('u_order', '>', workflow.scratchpad.currentOrder);
reqTask.addQuery('sys_id', sysID);
gs.log("SYS ID OF U ASSIGN is: " + reqTask.sys_id +" SYS ID OF CURRENT IS" + sysID);
reqTask.orderBy('u_order');
reqTask.query();
The table is u_request_tasks_definition. it contains a reference field named u_accociated_item that take a vlue from the sc_cat_item table. I want to fetch the ID of the sc_cat_item that is referenced in the u_accociated_item column.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 12:06 AM
var reqTask = new GlideRecord('u_request_tasks_definition');
reqTask.addQuery('u_order', '>', workflow.scratchpad.currentOrder);
reqTask.addQuery('u_associated_item.sys_id', current.cat_item.toString());