Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideQuery - Querying ritm variables

Ankita9793
Tera Contributor

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 : 

    new GlideQuery('sc_req_item')
        .where('active', true)
        .where('cat_item.name', 'GIAM Revoke Request')
        .where('ritm.variables.recert_id', 'HBEU-GB-A-BYODGFE-01') //issue with this statement 
        .where('approval', 'approved')
        .where('state', 'IN', [1, 2])
        .select(['u_beneficiary.u_country', 'number'])
        .forEach(function (reqItem) {
        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
        });

Updated script : 
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') // Added join query
    .join('sc_item_option', 'sc_item_option', 'sys_id') // Added join query
    .where('sc_item_option.item_option_new.name', '=', 'recert_id')
    .where('sc_item_option.value', '=', 'HBEU-GB-A-BYODGFE-01')
    //.where('variables.recert_id', 'HBEU-GB-A-BYODGFE-01')
    .where('approval', 'approved')
    .where('state', 'IN', [1, 2])
    .select(['u_beneficiary.u_country', 'number'])
    .forEach(function(reqItem) {
        gs.info("tetst" + 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
            });

TIA!!
       
0 REPLIES 0