- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 03:43 AM
How I can use system properties here? I want to filter out some locations and those locations I want to keep it in sys_properties. I tried but was not able to achieve.
Please suggest.. Thanks in advance...
Below is working client callable script include, only I want to use system properties instead of encodedquery
var FilterOutOfScopeLocations = Class.create();
FilterOutOfScopeLocations.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getInScopeCases: function() {
var arr = [];
var gr = new GlideRecord('xyz');
queryString = 'reported_person.location.countryNOT LIKEChina^reported_person.location.countryNOT LIKERussia^reported_person.location.countryNOT LIKENetherlands^reported_person.location.countryNOT LIKEBelgium^reported_person.location.countryNOT LIKEIsrael^reported_person.location.countryNOT LIKETaiwan^reported_person.location.countryNOT LIKESingapore';
gr.addEncodedQuery(queryString);
// gr.addQuery('reported_person.location.country', gs.getProperty('sp.filterOutOfScopelocations.country'));
gr.query();
while (gr.next()) {
arr.push(gr.sys_id.toString());
}
return 'sys_idIN' + arr;
},
type: 'FilterOutOfScopeLocations'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 09:57 AM
Give another try like this.
var getIncDetailsRow = Class.create();
getIncDetailsRow.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myFun: function(){
var arr = [];
var grp = new GlideRecord('sys_properties');
grp.get('name','MYTEST'); // add your properties name
var prop = grp.getValue('value').split(',');
var gr = new GlideRecord('incident');
for(var i = 0;i<prop.length; i++)
gr.addQuery('short_descriptionNOT LIKE'+prop[i]);
gr.query();
while(gr.next()){
arr.push(gr.getUniqueValue());
}
return arr;
},
type: 'getIncDetailsRow'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 07:25 AM
Thanks a lot Harshvardhan..
I have used the comma separated values in system properties.
Value-- China,Russia,Netherlands,Belgium,Israel,Taiwan,Singapore
Type -- String
However, its not giving the expected result, not sure why. Any suggestion?
But the encoded query was working which I had shared . I wanted to avoid the hardcoded values.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 07:32 AM
Can you validate the row count log and same way apply the filter on table list view and see the number of row returning there , if you see my demo result i tested it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 09:14 AM
I checked via background script ,I am getting the correct set of records ,but when I am calling the script include in reports, its returning me the incorrect set of data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 09:57 AM
Give another try like this.
var getIncDetailsRow = Class.create();
getIncDetailsRow.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myFun: function(){
var arr = [];
var grp = new GlideRecord('sys_properties');
grp.get('name','MYTEST'); // add your properties name
var prop = grp.getValue('value').split(',');
var gr = new GlideRecord('incident');
for(var i = 0;i<prop.length; i++)
gr.addQuery('short_descriptionNOT LIKE'+prop[i]);
gr.query();
while(gr.next()){
arr.push(gr.getUniqueValue());
}
return arr;
},
type: 'getIncDetailsRow'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2021 10:09 AM
your updated script:
var FilterOutOfScopeLocations = Class.create();
FilterOutOfScopeLocations.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getInScopeCases: function() {
var arr = [];
var grp = new GlideRecord('sys_properties');
grp.get('name','sp.filterOutOfScopelocations.country');
var prop = grp.getValue('value').split(',');
var gr = new GlideRecord('xyz');
for(var i = 0 ; i <prop.length ;i ++)
gr.addQuery('reported_person.location.countryNOT LIKE',prop[i]);
gr.query();
gs.log('Row Count is '+ gr.getRowCount());
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
return arr;
},
type: 'FilterOutOfScopeLocations'
});