How can I use system properties in the client callable script include

neha49
Kilo Expert

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'
});

1 ACCEPTED SOLUTION

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'
});

View solution in original post

14 REPLIES 14

Harsh Vardhan
Giga Patron

you can use  gs.getProperty() in your client callable script include to access the properties value. 

 

 

Harsh Vardhan
Giga Patron

eg:

 

var FilterOutOfScopeLocations = Class.create();
FilterOutOfScopeLocations.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getInScopeCases: function() {
var prop =  gs.getProperty('<properties NAme>'); // add properties name
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'
});

Harsh Vardhan
Giga Patron

For further details about the method , have a look on doc link. 

 

Use Application Properties

Harsh Vardhan
Giga Patron

Can you try now.

 

 

var FilterOutOfScopeLocations = Class.create();
FilterOutOfScopeLocations.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getInScopeCases: function() {
var arr = [];
var prop = gs.getProperty('sp.filterOutOfScopelocations.country').split(',');
var gr = new GlideRecord('xyz');
for(var i = 0 ; i <prop.length ;i ++){
gr.addEncodedQuery('reported_person.location.countryNOT LIKE',prop[i]);
}
gr.query();
gs.log('Row Count is '+ gr.getRowCount());
while (gr.next()) {
arr.push(gr.sys_id.toString());
}
return 'sys_idIN' + arr;


},
type: 'FilterOutOfScopeLocations'
});

 

Make sure you have added value in comma separated in your properties.