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

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

5 REPLIES 5

Thank you, this is working