how to call script include into service catalog variable advance reference qualifier

Deepa12
Tera Contributor

Hi,

 

I have written below script include to fetch category values:

var RemoveGPS = Class.create();
RemoveGPS.prototype = {
    initialize: function() {
        
    },
getcategory: function()
{
var category_array = new Array();
 
        var cate = new GlideRecord('sys_choice');
        cate.addQuery('name', 'STARTSWITH', 'incident');
        cate.addQuery('language', '=', 'en');
        cate.addQuery('element', 'STARTSWITH', 'category');
        cate.addQuery('inactive', '=', 'false');
        cate.addQuery('value', 'NOT LIKE', 'GPS%');
        cate.addQuery('value', 'NOT LIKE', 'WFM%');
     cate.query();
 
        while (cate.next()) {
            category_array.push(cate.value.toString());
 
        }
        return category_array;
},
 
    type: 'RemoveGPS'
};
 
THen i called this script include into Service catalog Variable:
Deepa12_0-1695225089258.png

 

In service portal, the category not fetching correctly. it showing all the values. please let me know the corrections.

 

Thanks,

 

1 ACCEPTED SOLUTION

Hi,
This can be done using contain or startswith, what she need is does not start with.



Thanks and Regards,

Saurabh Gupta

View solution in original post

15 REPLIES 15

Vishal Birajdar
Giga Sage

Hi @Deepa12 

 

Can you try updating below line.

 

  return category_array.toString();

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

sorry, it didnt work.

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
What do you want to achieve with this?

You can write below query in reference qualifier field-

name=incident^element=category^inactive=false^language=en^valueNOT LIKEGPS^valueNOT LIKEWFM



Thanks and Regards,

Saurabh Gupta

Hi Saurabh,

 

Thanks for reply, if i use this query into reference qualifier - name=incident^element=category^inactive=false^language=en^valueNOT LIKEGPS^valueNOT LIKEWFM 

it's filtering - all the categories which contains GPS, WFM. 

But my requirement is - filter the values starts with GPS,WFM.

so that i tried to create script include to filter out starts with the values GPS.