gs.getproperty not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 04:50 AM
Hi All,
I am using script include in report for some complex query. To make this dynamic i am taking some values from sys_properties table using gs.getProperty() method. But when i use it in script include it is not working. same script is working when i checked by running in background. Is this an expected behavior? How we can overcome this problem?
script include:
name: getIncidents
client callable: true
script:
function getIncidents()
{
var arr = [];
var query = gs.getProperty('Custom.incident.query');
var gr = new GlideRecord('incident');
gr.addEncodedQuery(query.toString());
gr.query();
while(gr.next())
{
arr.push(gr.sys_id+'');
}
return arr.toString();
}
Form list view, i am calling it as
sys id --is one of-- javascript:getIncidents()
Build version: isthanbul
Thanks and regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 10:24 PM
Did entire encoded query worked for you (active=true^assignment_group=something)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 03:05 PM
also, please check what do you get here with this log,
function getIncidents(){
var arr = [];
gs.log('System Property: ' + gs.getProperty('Custom.incident.query'));
var query = 'active=true';
var gr = new GlideRecord('incident');
gr.addEncodedQuery(query.toString());
gr.query();
while(gr.next())
{
arr.push(gr.sys_id+'');
}
return arr.toString();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 05:49 AM
hey Giri,
share your code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 06:05 AM
Anyone else what to ask user to share code? lol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2018 07:07 PM
gs.getProperty is already returning a string value. Why are you converting the property to string?
gr.addEncodedQuery(query.toString());
Try ;
gr.addEncodedQuery(query);