The CreatorCon Call for Content is officially open! Get started here.

get columns in incident_sla using Table API

kanikag
Tera Contributor

I am using sys_db_view to get sysid of incident_sla view, then I am using sys_db_view_table with view=sysid to get tables in view which are incident and task_sla.  Now to get columns used in view for these tables I am using sys_db_view_table_field and giving view_table as sysid of table but it is empty. 

The above procedure works well for custom made view but is not giving columns detail for incident_sla, please help me understand why sys_db_view_table_field doesnt have info of columns in tables used to create view and how to get them

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@kanikag 

database view just joins 2 or more table and is not an actual table in "sys_db_object"

But I was able to get correct count when I used table API on incident_sla

Incident -> Urgency -> 1 High (Total 20 Count)

AnkurBawiskar_0-1749723274840.png

API Gave 20 count

AnkurBawiskar_1-1749723350574.png

 

AnkurBawiskar_2-1749723382451.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

kanikag
Tera Contributor

I am looking for schema for columns used in incident_sla, for example for tables we can get it using sys_dictionary, how to get it for incident_sla? What does it mean if  sys_db_view_table_field is empty for sysid of incident and task_sla tables with sysid of incident_sla view?

@kanikag 

you won't find the fields in sys_dictionary as it's not an actual table.

you can use the table API on that database view table without any query and see the fields

That's what I used and then applied the query for the urgency

The fields look like this prefix_columnName

Example: inc is the prefix and urgency is the column

So I used inc_urgency=1 in the query in table API

Similarly taskslatable_original_breach_time -> taskslatable is the prefix and original_breach_time is the column 

AnkurBawiskar_0-1749724897505.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@kanikag 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader