
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎09-06-2021 11:27 AM
Many of us are aware of using the Before Query business rule to restrict access to records of any table. Also there are some OOB business rules which restrict access to system table records to non-admin users and one of them is the User [sys_user] table.
We have been struggling to find a way so that we can allow inactive users to be available for selection on some reference fields/ Catalog Variables. Sometimes we want to show inactive users in the reference field for selection in some selected cases but we need to make it available for all users (or users with particular roles). This can lead to a misuse of the functionality or creating tickets on Behalf of inactive users.
Below community question motivated me to write this article:
If we want to show inactive users without affecting other OOB functionalities we need to do some changes to Business Rule, Reference fields/Variables and add one custom field on the user table.
Step 1: Create a custom field/column on User [sys_user] Table:
Step 2: Update OOB Before Query business rule script:
A very very small change 🙂
var queryString = current.getEncodedQuery();
if(queryString.indexOf('u_show_inactive')<0) // use name of your new Column here
current.addActiveQuery();
Or deactivate OOB BR and create a similar business rule with above script as per best practice of not updating OOB BR.
Step 3: Update Reference Field/ Variable reference qualifier condition:
You just need to make another small change to all your reference fields/Variables where you want to show inactive users.
If already have some qualifier condition applied then also you need to add this additional condition.
or something like this:
This setup will work for all your fields where you add an additional reference qualifier condition with custom column name and it will not affect any existing setup because this custom field is not used in any of the filter conditions.
Kindly mark this article as helpful if this Helps you to solve your requirement. Let me know if you have any queries or want to suggest any changes.
Note: Similar way (by checking applied query with the help of getEncodedQuery()) you can control any Before Query Business rule behavior, but need to be very very careful while making any changes.
Thank you!
Anil Lande
- 5,413 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Dear Anil,
Can you please elaborate a bit on the precautions or care to be taken as mentioned in your note at the end of the above article?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Jeevan,
I hope you found it interesting, as you read it till last line 🙂
As this is before query business rule and it will execute every time the table is queried (either through script, user interaction etc).
I have suggest to make use of getEncodedQuery() and look for your keywords in the query.
var queryString = current.getEncodedQuery();
if(queryString.indexOf('keywords')<0) // use name of your new Column here
current.addActiveQuery();
If by any chance this keyword if present/absent in the query applied to get record from table then your logic may fail. That can lead to any type of issues (like wrong set records returned by query, same will result in updating wrong records, wrong calculations, exposing critical data to end users etc).
So we need to be vary particular about using before query. Use proper keywords and test all possible scenarios. (Avoid using it on system table if you are not aware about complete functionalities.)
There are lot many reasons, let me know if you need more information.
Thanks,
Anil Lande

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi. Thank you for this solution. I just have one question.
What is the name of the OOB Business Rule that you made the small change to? I have found 2 of them and I want to verify that I am updating the correct one.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
For those coming upon this solution later, I have found the script to update. It is called "user query":