Need help on User query business rule

Bharath Musku
Tera Contributor

Hello,

 

advance thanks on responding this issue!!

 

 We have requirement to show all users(active and inactive) for managers group only on one of catalog item, tried  below code on existing User Query BR

 

Business Rule 

var query_from_cat_item = (current.getEncodedQuery().indexOf("called_from_cat_item=true")>-1);
if(gs.getSession().isInteractive() && !(gs.hasRole("admin") && !((gs.getUser().isMemberOf('Managers group name')) && query_from_cat_item)){
current.addActiveQuery();
}
Added in variable reference qualifier-"called_from_cat_item=true"
 
It is working but the variable is in variable set and included other catalog items as well, need to show it only on specific catalog item.
3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

A Query BR is going to affect the table system-wide.  What you need to do is hide the variable set variable on this Catalog Item and create a variable in this Catalog Item to replace it, then change the reference qualifier to add your criteria in the qualifier itself or by calling a Script Include

But that particular variable set variable has multiple scripts and it is very painful to update it

sidd07
Tera Contributor

You may try this - In the variable, you can use advanced reference qualifier and add a script, the script checks the sys_id of the current catalog item and only adds the the reference qualifier - "called_from_cat_item=true" if sys_id of current catalog item matches the sys_id of the specific catalog item where you need it.

 

So your variable reference qualifier script will look something like this 

javascript: checkCatalogItem(current.cat_item.sys_id)

and in the "checkCatalogItem" function you do the necessary checks and return the query for reference qualifier accordingly.