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

Revanth Karra
Tera Expert

Dear Deepa12,

 

Hi @Deepa12 . Hope you're doing great! 

 

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', 'CONTAINS', 'GPS%');
    cate.addQuery('value', 'CONTAINS', 'WFM%');
   cate.query();
 
    while (cate.next()) {
      category_array.push(cate.value.toString());
 
    }
    return category_array;
},

 

Can you please try and let me know if it's working?

 

Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer