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
‎07-12-2018 02:54 AM
Hello @Venkat
Once you check the script include as client callable and you call it from a filter it means that it will be executed on client side
this is why gs.getProperty is not working and gs.log will not work also.
What you can do is a GlideRecord on sys properties tables to get your value
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2018 04:31 AM
gs.getProperty() is faster than doing a query on sys_properties because the properties are cached for performance reasons.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2018 04:34 AM
But gs.getProperty is not working in this case there is no other solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2018 04:46 AM
He also said gs.log() wasn't working which makes me think there is a broader issue happening here.
I made a few tweaks to his script and it works fine with the following setup. There were a couple things around the array management that could have been improved (notably getValue() and join())
function getIncidents() {
var arr = [];
var query = gs.getProperty('Custom.incident.query');
var gr = new GlideRecord('incident');
gr.addEncodedQuery(query);
gr.query();
gs.info(gr.getRowCount() + ' records found');
while(gr.next()) {
arr.push(gr.getValue('sys_id'));
}
return arr.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2020 07:53 PM
Hello
I tried several methods and found a successful alternative.
Alternative.
1. Execute the subflow by the system user.
2. Change the referenced value to user preference.
Cases of failure.
1. Refer to the system properties.
2. Use GlideRecord to refer to system properties.
3. Impersonate and refer to system properties.
Some users may not have read permission for these.
function TestQueryString() {
// Subflow: gs.getProperty('glide.installation.name') by System user
var subflowOutput = sn_fd.FlowAPI.executeSubflow('global.Test_Simple_Subflow');
var gr = new GlideRecord("sys_properties");
gr.get("name", "glide.installation.name");
var output = 'UserName ' + gs.getUserName() + ' >> Subflow ' + subflowOutput.output + ' >> getProperty ' + gs.getProperty('glide.installation.name') + ' >> GlideRecord ' + gr.getValue('value') + ' >> User Preference ' + gs.getUser().getPreference('sp.portal');
//UserName itil >> Subflow Demo Server(system) >> getProperty undefined >> GlideRecord null >> User Preference sp
return output;
}