Dynamic Filter Option with gs.getProperty()

Lukasz Bojara
Kilo Sage

Hello,

Maybe someone can share some light on this case:

Requirement: Filter the list of incidents (Report on Dashboard) based on assignment group sys_id kept in a system property.
Solution: Create a Dynamic Filter option
Problem: Filter returns empty when gs.getProperty() is used in Script Include.

Script Include code (:

function GetDefaultGroup() {
	return gs.getProperty('test.group');
}

find_real_file.png
Dynamic Filter Option Configuration:

find_real_file.png
Result:

find_real_file.png

Additional information:

 - Additional information: Checked with hardcoded sys_id in the script include, it works.

 - Checked configuration without script include and used gs.getProperty() directly, it does not work.

 

Anyone has an idea how to solve it?

9 REPLIES 9

This seems like a product issue to me. I removed the getProperty part and replaced with a gliderecord query to sys_properties table and the same script works.

 

var glideObject = new GlideRecord('sys_properties');
if (glideObject.get('c2715bce1b5508108ed631d7dc4bcb4e')) { //replace the property sys_id
answer = glideObject.getValue('value');
}

 

So, you can use this as a workaround and contact support for the said issue.

DrewW
Mega Sage
Mega Sage

Have you checked the system log for script errors?  Depending on when they runs the gs (GlideSystem) object may not be defined and you may have to declare one.

 

schorsch
Tera Contributor

@Lukasz,

I had the same issue (use gs.getProperty in the client callable script include which is used by the dynamic filter), it isn't working. But when I put in the content (value) of the prop in the Script Include (variable with string) it works....
Found this community article....
https://community.servicenow.com/community?id=community_question&sys_id=45d98fe5db5cdbc01dcaf3231f96...

... see comment of khadija at the end - this explains what happens. The only thing is that the workaround from khadija (getting the prop vi GlideRecord) isn't working too (for non-admin users) - seems because of restrictions on ACLs of sys_properties table (read- access is not granted to "non admin" users).

So at all it seems, there is only the possibility to use a variable with the "intended" value of the sys_prop. in the client callable Script Include (which is necessary that the code is executed via a dynamic filter).

Do anybody else have another idea?

Replacing the gs.getProperty with gliderecord should work. Read ACL does not apply for Gliderecords in script includes as far as I know. Are you sure that your script does not have any other issue?

Oh my goodness...I wasted so much time trying to get this to work. THANK YOU!!!!