Reference field from a table gives Undefined value

Lyubomir1
Tera Contributor

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!

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

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());


View solution in original post

4 REPLIES 4

fkhan
Kilo Guru

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);


Lyubomir1
Tera Contributor

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.


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.


Kalaiarasan Pus
Giga Sage

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());