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.

Script include to query RITM from Request

tsoct
Tera Guru

When I query from Request tqble, the script includes return null . What could have gone wrong?

 

Script include

Client callable (checked)

Accessible from All Application Scopes

getFinanceRitm: function() {
        var arr = [];
        var gr = new GlideRecord("sc_req_item");
        gr.addEncodedQuery("cat_item.sc_catalogsLIKEe0d08b13c33d1921e5f510100a9a"); //Finance Catalog
        gr.query();
        while (gr.next()) {
            arr.push(gr.request.getUniqueValue());
        }
        gs.print("Request Number : " + arr);
        return arr.toString();

 

Query from Request:

sysId is one of javascript:new global.CustomQueryUtils().getFinanceRitm()

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @tsoct ,

 

Please try the updated code below:

 

Script Include:

 

getFinanceRitm: function() {
        var arr = [];
        var gr = new GlideRecord("sc_req_item");
        gr.addEncodedQuery("cat_item.sc_catalogsLIKEe0d08b13c33d1921e5f510100a9a"); //Finance Catalog
        gr.query();
        while (gr.next()) {
            arr.push(gr.request);
        }
        gs.print("Request Number : " + arr);
        return arr.toString();
    },

 

 

Please consider marking my reply as Helpful and/or Accept Solution, if it helps. Thanks!

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @tsoct ,

 

Please try the updated code below:

 

Script Include:

 

getFinanceRitm: function() {
        var arr = [];
        var gr = new GlideRecord("sc_req_item");
        gr.addEncodedQuery("cat_item.sc_catalogsLIKEe0d08b13c33d1921e5f510100a9a"); //Finance Catalog
        gr.query();
        while (gr.next()) {
            arr.push(gr.request);
        }
        gs.print("Request Number : " + arr);
        return arr.toString();
    },

 

 

Please consider marking my reply as Helpful and/or Accept Solution, if it helps. Thanks!

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

dgarad
Giga Sage

Hi @tsoct 

 try the below code.

getFinanceRitm: function() {
        var arr = [];
        var gr = new GlideRecord("sc_req_item");
        gr.addEncodedQuery("cat_item.sc_catalogsLIKEe0d08b13c33d1921e5f510100a9a"); //Finance Catalog
        gr.query();
        while (gr.next()) {
            arr.push(gr.request.sys_id.toString());
        }
        gs.print("Request Number : " + arr);
        return arr
    },

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad