- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 08:56 AM
Hi,
I have written below script include to fetch category values:
In service portal, the category not fetching correctly. it showing all the values. please let me know the corrections.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 12:00 PM
Hi,
This can be done using contain or startswith, what she need is does not start with.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 09:56 AM
Hi,
Use below query for the same-
name=incident^element=category^inactive=false^language=en^valueSTARTSWITHGPS^valueSTARTSWITHWFM
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 10:24 AM
Hi,
You can use below script in your script include-
var RemoveGPS = Class.create();
RemoveGPS.prototype = {
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.query();
while (cate.next()) {
var ch=cate.getValue('value').toUpperCase();
if(ch.indexOf('GPS')!=0 && ch.indexOf('WFM')!=0)
category_array.push(cate.getUniqueValue());
}
if(category_array.length>0)
return "sys_idIN"+category_array.join(",");
else
return "sys_idINnothing";
},
type: 'RemoveGPS'
};
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 09:09 AM
It might just be eaiser to input an encoded query into the reference qualifer, it looks like your script include is just doing filtering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 09:56 AM
i am unable to filter through encoded reference qualifier - category values is not Startswith GPS.
NOT LIKE operator filter check whole statement - whether category contains GPS values from category.
name=incident^element=category^inactive=false^language=en^valueNOT LIKEGPS^valueNOT LIKEWFM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 11:08 AM
In Surabh's script, if statement should compare with -1 not 0
if(ch.indexOf('GPS')!=-1 && ch.indexOf('WFM')!=-1)