To create related list based on RITM form variable value

Divya28
Kilo Explorer

My requirement is to  create a related list under stockroom table which displays the RITM related to the specific stockroom, I am trying to establish the connect between the two tables using RITM form variable value from Variable Ownerships(sc_item_option_mtom) table, below is the code is am using Relationship

var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('sc_item_option.value',parent.sys_id);
gr.query();
var tskIDArr = [];
while (gr.next()) {
tskIDArr.push(gr.request_item.number);

}
var tskIDStr = tskIDArr.join();
current.addQuery('number', tskIDStr);

Not sure what is the problem.

Could anyone please correct me where I am going wrong

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

I hope you have configured it like below:

find_real_file.png

And use below script:

 

(function refineQuery(current, parent) {

    var gr = new GlideRecord('sc_item_option_mtom');
    gr.addQuery('sc_item_option.value', parent.sys_id);
    gr.query();
    var tskIDArr = [];
    while (gr.next()) {
        tskIDArr.push(gr.request_item.number);

    }
    var tskIDStr = tskIDArr.join();
    current.addQuery('number','IN', tskIDStr.toString());

})(current, parent);

 

Thanks,
Anil Lande

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

Hi,

so you have variable which holds stockroom information?

Is that variable a reference type to alm_stockroom?

Regards
Ankur

yes, that variable is used in multiple forms so I tried by reading the value and that variable is reference variable to stockroom table

then directly use this and no need to query any table

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);

	// give the sysId of the variable from item_option_new table
	
	current.addQuery('variables.variableSysId', parent.sys_id);
		
})(current, parent);

Regards
Ankur

Anil Lande
Kilo Patron

Hi,

I hope you have configured it like below:

find_real_file.png

And use below script:

 

(function refineQuery(current, parent) {

    var gr = new GlideRecord('sc_item_option_mtom');
    gr.addQuery('sc_item_option.value', parent.sys_id);
    gr.query();
    var tskIDArr = [];
    while (gr.next()) {
        tskIDArr.push(gr.request_item.number);

    }
    var tskIDStr = tskIDArr.join();
    current.addQuery('number','IN', tskIDStr.toString());

})(current, parent);

 

Thanks,
Anil Lande