Is there any best alternative way to overcome this ?

Vijay Talupula
Tera Guru
Tera Guru

Hi All,

I am retrieving the total (active & inactive) record count over a record producer form through Client script and script include which is working fine.

But, there is a OOB BEFORE - QUERY business rule which is running on User [sys_user] table which restricting the non admin users to get the inactive record count.

So, as per my requirement, I am thinking to modify it to allow the non admin role.

I would like to know that, is there any alternative way to overcome this instead of modifying the OOB business rule ?

1 ACCEPTED SOLUTION

Hi All,



For others benefit, without modifying the OOB business rule, I have achieved this as mentioned below,



Bypassing the BR:


As I am querying (not insert/update/delete), I have used 'setWorkflow(false)' while querying the User table in script include to bypass business rules with a condition check "if current user contains the non-admin role" otherwise it runs as usual.


View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,



Since the onQuery business rule will run based on the condition and it will restrict the rowCount based on what query has been applied. As per my knowledge the only way to do this is to modify the onQuery business rule condition and then test the functionality thoroughly.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi All,



For others benefit, without modifying the OOB business rule, I have achieved this as mentioned below,



Bypassing the BR:


As I am querying (not insert/update/delete), I have used 'setWorkflow(false)' while querying the User table in script include to bypass business rules with a condition check "if current user contains the non-admin role" otherwise it runs as usual.


Hi Vijay,



Great that you were able to achieve your requirement.


Could you mark the answer as correct and hit like. Thanks in advance.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader