Business Rule (before query) need to know if triggered via related list ... how???

Zod
Giga Guru

Due to relevant filter values on dashboards, users need to generally query all records on certain tables (so have ACLs accordingly to see all records).

However, through a Business Rule on before query, I limit what they really should be able to see and set the query accordingly.

Everything works fine, except within a related list. There, the user still sees all the items they are supposed to see, but the filter condition (in the related list) is not taken into account anymore.

So, what I need is to find out how to abort the business rule and return if the request comes via a related list.

All methods I know to determine this are client-side and won't work within a server-side script.

Can anyone tell me how to find out within the script if the query request is coming from a related list?

 

Thank you.

PS: Chat CPT Answer I can get myyself - but they are not working.

1 ACCEPTED SOLUTION

Mark Manders
Mega Patron

TL'DR: you will need to control related lists through reference qualifiers or ACL's. Query BR's aren't evaluated on related lists. Explanation below.

You could try and make your QBR into a Script Include and call that from your reference qualifier.

Query Business Rules (BRs) are designed to filter the data that is returned by a query before it is displayed to a user, typically in a list or form. They are evaluated on the server side when a query is made to the database, which allows for the manipulation of the dataset that a user can see based on certain conditions.

When it comes to related lists in ServiceNow, the system uses a different mechanism to control the display of data, which involves Reference Qualifiers and Access Control Rules (ACLs) rather than Query BRs. Related lists are essentially lists of records from a different table that have a defined relationship to the current record being viewed. The data displayed in these lists is filtered by reference qualifiers, which are conditions set on the reference field that determines what records are selectable in a related list. Additionally, ACLs control the access to data based on the user's permissions, roles, and other conditions.

Query BRs are not evaluated in the context of related lists because the system relies on reference qualifiers and ACLs to manage the visibility and access to related list data. This design choice is made for efficiency and performance reasons, as evaluating Query BRs for each record that could potentially appear in a related list could be resource-intensive and slow down the system. Instead, by utilizing reference qualifiers and ACLs, ServiceNow provides a more optimized way to control access to and display of related list data, ensuring that users see only the relevant information they are permitted to access.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

4 REPLIES 4

Mark Manders
Mega Patron

TL'DR: you will need to control related lists through reference qualifiers or ACL's. Query BR's aren't evaluated on related lists. Explanation below.

You could try and make your QBR into a Script Include and call that from your reference qualifier.

Query Business Rules (BRs) are designed to filter the data that is returned by a query before it is displayed to a user, typically in a list or form. They are evaluated on the server side when a query is made to the database, which allows for the manipulation of the dataset that a user can see based on certain conditions.

When it comes to related lists in ServiceNow, the system uses a different mechanism to control the display of data, which involves Reference Qualifiers and Access Control Rules (ACLs) rather than Query BRs. Related lists are essentially lists of records from a different table that have a defined relationship to the current record being viewed. The data displayed in these lists is filtered by reference qualifiers, which are conditions set on the reference field that determines what records are selectable in a related list. Additionally, ACLs control the access to data based on the user's permissions, roles, and other conditions.

Query BRs are not evaluated in the context of related lists because the system relies on reference qualifiers and ACLs to manage the visibility and access to related list data. This design choice is made for efficiency and performance reasons, as evaluating Query BRs for each record that could potentially appear in a related list could be resource-intensive and slow down the system. Instead, by utilizing reference qualifiers and ACLs, ServiceNow provides a more optimized way to control access to and display of related list data, ensuring that users see only the relevant information they are permitted to access.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hello Mark,

I am trying to sort values in a lookup select box variable on a catalog item.    I have tried multiple ways but is not working.   Adding ORDERBYuOrder to qualifier adding ref_ac_order_by trying a before query but nothing is working.  Any ideas?

Thanks,

Chad

It is not helpful to put a completely unrelated question into some one else's question.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Zod
Giga Guru

Found something helpful ... 

When using current.getEncodedQuery(); you are more or less able to know where u are coming from ... and also some workaround cound be added here ... . So I was finally able to get by things done ..