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.

join() and get.Value instead of push and toString()

Viktor Stepanov
Mega Contributor

Hello all,

in the following script:

    function testing {
        
    var sysIDkey = [];
    var GRfilter = new GlideRecord('incident');
    GRfilter.addEncodedQuery('category='hardware');
    GRfilter.query();
    while (GRfilter.next()) {
        sysIDkey.push(GRfilter.sys_id.toString());
        
    }
        
    return sysIDkey;
    }

I would need to use join() instead of push and getValue instead of toString().

GRfilter.getValue('sys_'id) works fine, but I'm not able to replace push with join() in any modification - result is always javascript:testing() //being used as scripted filter.

 

Any ideas are most welcomed.

 

Thanks,

VS

5 REPLIES 5

Same issue I cant pass an array with array.join() or array.tostring via script include to an advanced reference qualifier calling script include. I am forced to use array.push(gr.sys_id+","); to get correct values while returning return 'sys_idIN' + array;

I cant use array.push(gr.sys_id) as after that using join or tostring doesnt work, while passing this to reference qualifier. if pass return array; however this does work and i do get directly a string in client script ajax call without using join or tostring - strange; but wont work in reference qualifier.

If anyone got nicer solution, i would prefer rather than forcing a comma myself in push.