GlideQuery - Querying ritm variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi all,
I need help with below scheduled job script, where i'm trying to query ritm variables. I understand, GlideQuery does not support querying on ritm variables so join has to be used. I have updated my code with join but it does not work, Please suggest.
Actual script :
Updated script :
TIA!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
46m ago
try this
var obj = {};
new GlideQuery('sc_req_item')
.where('active', true)
.where('cat_item.name', 'GIAM Revoke Request')
.join('sc_item_option_mtom', 'sys_id', 'request_item')
.join('sc_item_option', 'sys_id', 'sc_item_option') // Join sc_item_option_mtom.sc_item_option to sc_item_option.sys_id .where('sc_item_option.item_option_new.name', 'recert_id')
.where('sc_item_option.value', 'HBEU-GB-A-BYODGFE-01')
.where('approval', 'approved')
.where('state', 'IN', [1, 2])
.select(['u_beneficiary.u_country', 'number'])
.forEach(function(reqItem) {
gs.info("Number: " + reqItem.number);
var brambleSource = new GlideQuery('u_mobile_country_to_request_type')
.where('u_bramble_source', 'IN', ['EMEA', 'APAC', 'TURKEY', 'Germany'])
.where('u_country_code.u_lookup_country', reqItem.u_beneficiary.u_country)
.selectOne('u_bramble_source')
.orElse({
u_bramble_source: null
});
});
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
27m ago
Hi @Ankita9793 ,
Please review below code-
new GlideQuery('sc_req_item')
.where('active', true)
.where('cat_item.name', 'GIAM Revoke Request')
// Join to MTOM table
.join('sc_item_option_mtom', 'sys_id', 'request_item')
// Join to variable values table
.join('sc_item_option', 'sc_item_option', 'sys_id')
// Join to variable definition table (item_option_new)
.join('item_option_new', 'item_option_new', 'sys_id')
// Match variable name
.where('item_option_new.name', '=', 'recert_id')
// Match variable value
.where('sc_item_option.value', '=', 'HBEU-GB-A-BYODGFE-01')
.where('approval', 'approved')
.where('state', 'IN', [1, 2])
.select(['u_beneficiary.u_country', 'number'])
.forEach(function(reqItem) {
gs.info("Processing RITM " + reqItem.number);
var brambleSource = new GlideQuery('u_mobile_country_to_request_type')
.where('u_bramble_source', 'IN', ['EMEA', 'APAC', 'TURKEY', 'Germany'])
.where('u_country_code.u_lookup_country', reqItem.u_beneficiary.u_country)
.selectOne('u_bramble_source')
.orElse({ u_bramble_source: null });
});
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
