Table API - Get Child Table Fields

mattp
Tera Contributor

We have a use case where we want to query the cmdb_ci table for specific classes, and return fields from those classes that aren't on the base cmdb_ci table. An example would be 'kernel_release', which exists on the 'cmdb_ci_linux_server' table, but not on cmdb_ci. Is there a way to return the field 'kernel_release' when it exists when querying cmdb_ci over the table API?

Thank you!

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

Hi Matt,



You might want to give a try with this.



https://instnace.service-now.com/api/now/table/cmdb_ci?sysparm_fields=ref_cmdb_ci_server.classificat...




The idea here is, you can pass the field names of specific tables if you know the already to see the values


View solution in original post

9 REPLIES 9

rajeevlochan82
Mega Guru

I do not think so as Table API is out of box , so unless you write some custome web-service , there does not seem to any way to retrieve it from table api if the field does not directly exist in a table


I've put a little though into this for a use case I haven't gotten to yet, and didn't find an easy solution on the shelf.



I think... if you know the end class tables are of interest, you could do something like query each of those tables for the more specific droids you are looking for, then use an exclude filter in cmdb_ci to exclude the records you should already have based on a filter.



Apparently NOT IN works since sys_class_name is a pick list field.



.../api/now/table/cmdb_ci?sysparm_query=sys_class_nameNOT%20INcmdb_ci_server,cmdb_ci_hardware,cmdb_ci_computer&sysparm_fields=sys_class_name&sysparm_limit=1000


srinivasthelu
Tera Guru

Hi Matt,



You might want to give a try with this.



https://instnace.service-now.com/api/now/table/cmdb_ci?sysparm_fields=ref_cmdb_ci_server.classificat...




The idea here is, you can pass the field names of specific tables if you know the already to see the values


Perfect.   Thank you Srinivas. I was looking for exactly that and didn't find it the other day.