- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 03:06 AM
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
Solved! Go to Solution.
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 03:26 AM
Hi,
I hope you have configured it like below:
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 03:18 AM
Hi,
so you have variable which holds stockroom information?
Is that variable a reference type to alm_stockroom?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 03:40 AM
yes, that variable is used in multiple forms so I tried by reading the value and that variable is reference variable to stockroom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 07:26 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 03:26 AM
Hi,
I hope you have configured it like below:
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
Thanks
Anil Lande