- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2025 06:59 AM
Hi All,
I have created a system properties "a_b_c" where i have stored three sys ids of a catalog in form of a,b,c.
now this i have to use in business rule. when my catalog is any of this (a or b or c). then do xyz.
i have to put this sys property a_b_c in Encoded Query of a BR.
i have used but its not selecting that three catalog ids.
script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2025 05:44 PM
Hi @PawanKumarR
Try below script..
var sysIds = gs.getProperty('a_b_c').toString();
var encodedQuery = 'cat_itemIN' + sysIds;
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery("opened_by", current.getValue('u_owner_id'));
ritmGr.addEncodedQuery(encodedQuery);
ritmGr.addActiveQuery();
ritmGr.query();
while (ritmGr.next()) {
//YOUR LOGIC HERE
}
Hope this helps .
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2025 05:58 PM
Seems you need to debug your script. check the results of the query
gs.info('My script: query of sys_req_item found ' + ritmGr.getRowCount() + ' records for query: ' + encodedQuery);
before your 'if(ritmGr.next())' statement. and see what you get in the Script Log Statements module.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2025 06:18 PM
From a performance point of view, you can use the "IN" operator rather than OR. OR conditions cause additional database resources.
//getProperty allows for a second parameter
//to set a default value
var scCatItemSysIds = gs.getProperty('a_b_c', '');
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery("opened_by", current.u_owner_id);
ritmGr.addQuery('cat_item' , 'IN' , scCatItemSysIds);
ritmGr.addActiveQuery();
//use this if you're going to use "if" rather than "while" when looking at record
//ritmGr.setLimit(1);
ritmGr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 05:16 AM
not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 08:58 AM - edited 04-10-2025 01:21 PM
The value of the sys_properties record is a comma-separated list of sys_id values. A BR that runs Before for Query would have:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (!(gs.hasRole("admin") || gs.hasRole("user_admin")) && gs.getSession().isInteractive()) {
current.addQuery('cat_item', 'IN', gs.getProperty('a_b_c'));
}
})(current, previous);
adjust role check as desired so not all users are limited in what they see.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 01:08 PM
Tried with above too but not working. below is the full code.