Getting table field and datatype using api

sandipc
Kilo Explorer

How can I get table field and datatype using api?
For example,if I want to get all fields and datatype of incident table using api then is there any option to do that??

3 REPLIES 3

john_andersen
Tera Guru

You can query the system dictionary table with web services if you have the proper rights.

WSDL:

https://myinstance.service-now.com/sys_dictionary.do?WSDL

Then perform a "getRecords" query such as:



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sys="http://www.service-now.com/sys_dictionary">
<soapenv:Header/>
<soapenv:Body>
<sys:getRecords>
<name>{TABLE NAME GOES HERE}</name>
</sys:getRecords>
</soapenv:Body>
</soapenv:Envelope>


This will give you all of the fields on that table and any information on that field such as data type.

Field names are found in the "element" result. Data types are found in the "internal_type" element.


What type of rights should I have to make the query?





Thanks,
Sandip


It probably takes an admin role to do this. I wouldn't recommend an integration user having admin rights. I would create a new role for your integration. Then I would create a set of ACLs on that role that allow the reading of the sys_dictionary. Then apply that role to the user that you are using for your inbound integration calls.