GlideRecord query for specific inherited/child tables

chazz1
Mega Contributor

is there a way to query tables to exclude certain child tables?

for instance, i would like to query the task table and leave out planned_tasks. This way i can get all incidents, changes, problems, facilities, etc. etc without also grabbing projects, project tasks, etc. etc.



var tasks = new GlideRecord("task");
task.addQuery("actual_table_name", "ISNOT", "planned_task");
task.query();



If i can't do that then how would i get the TaskStateUtil instance of the actual table and not task? if i do a query on the task table i can get all kinds of different things, incidents, projects, project tasks. etc. etc. but when i load up the task state util for any of them all i get is the states for task no matter what overrides i have defined.

6 REPLIES 6

DubeyN
Mega Expert

Check below link, it explains it very well.

http://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/

ND


chazz1
Mega Contributor


i see that there is an INSTANCEOF operator. is there a way to NOT that? i am looking for all tasks that are NOT planned_tasks


DubeyN
Mega Expert

use != for this purpose.Like

var tasks = new GlideRecord("task");
task.addQuery("actual_table_name", '!=', 'planned_task');
task.query();

ND


chazz1
Mega Contributor

my code was just pesudo code. "actual_table_name" is not a column anywhere.

I am really asking if it is even possible to query table heirarchy.