REST API to get all fields ( with label, internal_type, mandatory attributes) for incident/problem table

Ragavan
Kilo Contributor

Use Case:
I'm writing an application which will create an incident or problem ticket in my ServiceNow instance. What I first need is metadata about the fields to create an incident or problem in the respective table. There could be user defined custom fields and also I need to render which fields are mandatory in the UI of my application. Then after getting inputs on the various fields I will submit a POST request to my instance create an instance/problem.

Issue:
I'm currently using the following query on sys_dictionary table for the metadata I need:
"api/now/table/sys_dictionary?sysparm_query=name=incident&sysparm_fields=column_label,mandatory,internal_type"
But, this query is not returning all the fields - for example the fields 'assigned to' and 'assignment_group' are missing in the result. Only a reduced set of entries from the incident table seems to be returned for this query on sys_dictionary table.

I have tried to get the metadata from sys_documentation table and also api/now/doc/table/schema API, but these are missing the 'mandatory' attribute for a field and again the result seems to be partial.

Can I get some help on how to get the information I desire using the REST API to ServiceNow instance?

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Interesting one! I don't know a solution from the top of my mind, have to do a brainstorm for this 🙂

Though the fields you are "missing", are actually all fields that come from table extension. For example, assigned to / state / description / etc. >>> all fields on the Task table, not Incident.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Interesting one! I don't know a solution from the top of my mind, have to do a brainstorm for this 🙂

Though the fields you are "missing", are actually all fields that come from table extension. For example, assigned to / state / description / etc. >>> all fields on the Task table, not Incident.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Harsh Vardhan
Giga Patron

you have to do here manual work to get the field details ( check for mandatory details )

how about if some fields are mandatory by UI Policy, client script, data policy. which you wont be able to get by using api. 

 

 

 

Harsh Vardhan
Giga Patron

another point here if you will filter on "sys_dictionary" table by using table name ( in your case incident) then you wont be able to get the "assigned to' and 'assignment_group" field because these fields are available on base table (task table)

 

you can simply put the filter on the sys_dictionary.list and you will see the result.

 

If my answer helped you, kindly mark it as correct and helpful.

Ragavan
Kilo Contributor

Thanks for the helpful replies. I understand that for a problem or incident, I need to combine fields from the parent table which is 'Task'.

On a related note, what is the parent table for the Agile Development tables - rm_epic, rm_story, rm_enhancement etc.? I can't seem to find this in the documentation.