Before Query Business Rule on Parent Table Only

Jim Coyne
Kilo Patron

Question: Is it possible to write a "Before \ Query" Business Rule that does not run on a child table?

For instance, I want to create a new "u_incident2" table which extends the incident table and then write a Business Rule that will only run on the incident table and not the new extended table. Basically, I want to filter out the records in the u_incident2 table when looking at the incident table, but show them when viewing the u_incident2 table specifically.

3 REPLIES 3

justin_drysdale
Mega Guru

Hi Jim,

Once you create your extended table, does it show in the table listing in the Business Rule? If so select the table from there.

If not run a condition,
if (current.getTableName() === "YourExtendedTablename") {
//code here
}


CapaJC
ServiceNow Employee
ServiceNow Employee

One clarification regarding the user of getTableName() - the result can vary depending on the GlideRecord.

Say I have INC0010003, and I have an "incident" GlideRecord for that sys_id. getTableName() will give "incident". If, however, my GlideRecord is on "task" for that same record, getTableName() will give "task".

getRecordClassName(), on the other hand, will give "incident" for both. It returns the sys_class_name value. For conditions on class, it is often more reliable.


Juan Carlos3
Kilo Explorer

try 

 current.addQuery('sys_class_name', current.getRecordClassName());}

:)...