Query business rules on child table is not applying to Parent table

Chaiatnya
Tera Contributor

Hi, I've written a query business rule on child table, but records are still visible on parent table, But when trying to open records, it is showing as record not found,

 

How to fix this issue.

4 REPLIES 4

sushantmalsure
Mega Sage
Mega Sage

Hello @Chaiatnya 

In my opinion this is not issue , thats the way it works.

Even product documentation says the same in 'points to consider' 

Details: https://docs.servicenow.com/en-US/bundle/utah-platform-security/page/administer/company-and-domain-s...

 

It is recommended to have before query BR on lowest hierarchy meaning if you want to restrict incidents then you are not supposed to create before query BR on task but on incident itself , and I believe you have done that.

Now the part when you are looking into incident records from task table, then query BR isnt executed but gets executed when user tries to open incident and user gets 'Record not found'.

 

In such cases consider this as side effect of before BR from child table but if you still want to get rid of this behaviour then you can think of another before query BR on task table and just filter out incidents from it (using  current.getTableName()!='incident').

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Chaiatnya
Tera Contributor

@sushantmalsure  Hi, Thanks! I've written on task table now, but the condition applied to all the child tables. For example i'm not able to see Request items assigned to some one. I only need to restrict for Incidents, Not other child tables

Can you share the script from task which you have written?

I just tried before query BR on task and added following in script

 

    current.addQuery('sys_class_name','!=','incident');
 
This restricted all incidents visibility from task table, by this way incidents will not be visible from task table list. If you have some specific conditions for such incidents then include that (may be similar to what you have in before query BR of child table)
 
Share the screenshot of the script, if this isnt understood .
 
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

nameisnani
Mega Sage

Hi @Chaiatnya 

 

There are a few reasons why a query business rule on a child table might not be applying to the parent table.

  • The query business rule might not be scoped to the parent table.
  • The query business rule might be using a filter that is not compatible with the parent table.
  • The query business rule might be using a join condition that is not compatible with the parent table.

To troubleshoot this issue, you can use the following steps:

  1. Check the scope of the query business rule. The scope of the query business rule should be set to the parent table.
  2. Check the filters used in the query business rule. The filters used in the query business rule should be compatible with the parent table.
  3. Check the join conditions used in the query business rule. The join conditions used in the query business rule should be compatible with the parent table.