restrict the filter options on service catalog field

pavam
Tera Contributor

I am having a reference field on the Service catalog form,

 

below is the screenshot

pavam_0-1727677054982.png

 

  and  level 3 form field is like below.

 

pavam_1-1727678966962.png

 

 

 

 and coming to script include, through the Reference qual.

 

 businessGroup: function() {
          var choices = [];
        var gr = new GlideAggregate('u_ehs');
        gr.groupBy('u_business_group');
        gr.query();

        while (gr.next()) {
            gs.log(" level3 in si in loop" + gr.u_business_group);
            choices.push(gr.getValue('u_business_group').toString());

        }
        //return JSON.stringify(choices);
        return 'sys_idIN' + chocies;
    },
 
..
 
In level 3 , reference field , dropdown list should come like , what ever the values present in the custom table .
 
But  here i am getting all the values as dropdown list from the reference table(reference table , refere 2nd screen shot, table name: x_emel_dat_business_group.
 
My desired output is , values preset in table: u_ehs , should come as dropdown in the  catalog item reference field.
 
 Can some one help me regarding this.
Appreciated your help.
Thankyou.
1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage
Giga Sage

Hi @pavam 

 

Correct the Typo in the Script Include:
There’s a typo in chocies. It should be choices.
return 'sys_idIN' + choices;

can you revisit the script and modify it

businessGroup: function() {
var choices = [];
var gr = new GlideAggregate('u_ehs');
gr.groupBy('u_business_group');
gr.query();

while (gr.next()) {
gs.log("level 3 in SI in loop: " + gr.getValue('u_business_group'));
choices.push(gr.getValue('u_business_group').toString());
}

return 'u_business_groupIN' + choices.join(',');
},

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

1 REPLY 1

Ravi Gaurav
Giga Sage
Giga Sage

Hi @pavam 

 

Correct the Typo in the Script Include:
There’s a typo in chocies. It should be choices.
return 'sys_idIN' + choices;

can you revisit the script and modify it

businessGroup: function() {
var choices = [];
var gr = new GlideAggregate('u_ehs');
gr.groupBy('u_business_group');
gr.query();

while (gr.next()) {
gs.log("level 3 in SI in loop: " + gr.getValue('u_business_group'));
choices.push(gr.getValue('u_business_group').toString());
}

return 'u_business_groupIN' + choices.join(',');
},

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/