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

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



Thanks and Regards,

Saurabh Gupta

Hi Saurabh,

 

1. i changed the category field type as - lookup selectbox and updated filter condition as mentioned by you.

2. i updated the script include with small modification:

getcategory: function() {
var category_array = [];
var cate = new GlideRecord('sys_choice');
cate.addQuery('name', 'incident');
cate.addQuery('language', 'en');
cate.addQuery('element', 'category');
cate.addQuery('inactive', 'false');
cate.addQuery('label', 'NOT LIKE', 'GPS%');
cate.addQuery('label', 'NOT LIKE', 'WFM%');
cate.addQuery('label', 'NOT LIKE', 'T&E%');
cate.addQuery('label', 'NOT LIKE', 'LVP%');
cate.query();

while (cate.next()) {
category_array.push(cate.getUniqueValue());
}
return "sys_idIN" + category_array.toString();
},

4. now its fetching the record which contains GPS value but not starts with GPS.

Only issue is: the latest value(which means recently added value) only not displaying.

but in the scrip back ground - its fetching correctly.

Script background:

Deepa12_0-1695276664077.png

 

Service Portal:

Deepa12_1-1695276738532.png

Pls assist me

 

Then your script should work.

 

 

maroon_byte
Mega Sage

Are you using Reference type variable? If so, then you will get values.

You will need to use 'Lookup Select Box'

1. 

maroon_byte_0-1695237473971.png

2. 

maroon_byte_1-1695237507596.png

3. 

maroon_byte_2-1695237542446.png

4. Saurabh's script

 

 

-O-
Kilo Patron
Kilo Patron

Entering encoded query:

 

name=incident^element=category^language=en^inactive=false^RLQUERYsys_choice.sys_id,=0,^valueSTARTSWITHGPS^ORvalueSTARTSWITHWFM^EQ^ENDRLQUERY

 

should do what you want: choices that don't start with GPS and don't start with WFM.