- 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 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 11:12 PM
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:
Service Portal:
Pls assist me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 12:14 PM
Then your script should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 12:21 PM
Are you using Reference type variable? If so, then you will get values.
You will need to use 'Lookup Select Box'
1.
2.
3.
4. Saurabh's script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 12:38 PM - edited ‎09-20-2023 12:56 PM
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.