Using sysparm_query like Reference Qualifier in URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 08:39 AM - edited 05-08-2024 08:41 AM
This is a similar post to https://www.servicenow.com/community/developer-forum/how-if-possible-to-use-script-include-for-entir...
In our use case, we want to control the applied table filter when a module/URL is loaded using one singular function which is coded per role. Using a simple example:
var clientUtilV1 = Class.create();
clientUtilV1.prototype = Object.extendsObject(AbstractAjaxProcessor, {
test1: function() {
return 'a83820b58f723300e7e16c7827bdeed2';
},
test2: function(){
return 'sys_id=a83820b58f723300e7e16c7827bdeed2';
},
type: 'clientUtilV1'
});
If I were to go to link 1 below, the query works as intended and returns the record with sys_id=a83820b58f723300e7e16c7827bdeed2
(because the link gets cut off, sysparm_query uses javascript: new global.clientUtilV1().test1();
However, if I use the link 2 below, the query returns all records and ignores the javascript call
(because the link gets cut off, sysparm_query uses javascript: new global.clientUtilV1().test2();
The function call in Link 2 drops the field in the effort of passing an entire encoded query, rather than the target value(s) for a specific field. This syntax is commonly used for Reference Qualifiers where you want to pass an entire encoded query. My question is this - is there a way to apply this Reference Qualifier like filter to sysparm_query (or another sysparm type parameter?) rather than having to do an individual script include per field? I ask because some user groups need the filter based on fields a/b/c, but other user groups need it based on fields d/e/f. For reasons I won't get into, this ideally needs to be driven all from the same URL.
Thanks!