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.

catalog variable values in servicenow

v-paulp
Tera Contributor

Hi 

There are two variables on a catalog item  " select_owner_of_the_reports" and "selects_the_reports_name'.

I want only those reports should show to "selects_the_reports_name" variable where the the created by user is the user on " select_owner_of_the_reports" variable.

I have written a script include for this,

 

var reports = Class.create();
reports.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    initialize: function() {
    },
    getReportInfo: function() {
        var value = current.variables.select_no_of_reports;
        var owner = current.variables.select_owner_of_the_reports;
        //if (value == 'Multiple Reports') {
            var answer = [];
            var gr = new GlideRecord('sys_report');
            gr.addQuery('created_by_user', owner);
            gr.query();
            while (gr.next()) {
                answer.push(gr.getValue('title'));
            }
            var qry = 'sys_idIN' + answer;
            return qry;
        //}
           
    },

    type: 'reports'
});
 
 
And added that script include in the Reference qualifier of that variable, but it is not working, it still showing all the reports on that variables.
 
vpaulp_0-1713424069316.png

Please let me know where am i making the mistake.

 

Thanks

Pradip Paul

5 REPLIES 5

Community Alums
Not applicable

Hi @v-paulp ,

Did you tried my solution? It works fine for you? If you need anything please let me know.

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak