0

I'm working with the ServiceNow API and I'm able to pull data from the Table API without issue. What I can't seem to find is any documentation on the different states that might be available on a specific table.

What I'd like, if possible, is to find an API call that will take in a table name and return a list of available states that can be set. Or, short of that, I'd just like to know if this data is even publicly available from ServiceNow.

Any direction is appreciated.

dst3p
  • 1,008
  • 11
  • 25

1 Answers1

2

States for fields are simply just stored in the sys_choice table. You can use the Table API like you said you were doing without issue, but to query the sys_choice table to get the available states:

sys_choice

  • table: your table name
  • element: your field name
  • language: en (or whatever language you want to use)
  • inactive: false

That query will give you a result set of all the relevant choices. The value to save in your field is stored in the value property of the results, and the name of the choice will be in the label property of the results.

Dylan Lindgren
  • 361
  • 2
  • 3
  • When I'm looking at my API explorer, `sys_choice` doesn't show up as a table. [This](https://community.servicenow.com/community?id=community_question&sys_id=432643a1db1cdbc01dcaf3231f9619f7) got me a bit closer on the `sys_choice` call, and I'm able to query, however, the values don't look like what i'd expect. This is the URL I'm requesting from - https:///api/now/table/sys_choice?sysparm_query=name%3Dincident&sysparm_limit=10. – dst3p Sep 10 '19 at 13:26
  • Talked to our ServiceNow admin, and our API account had ACL restrictions. I'll report back when the ACL is complete, but it sounds like that's why I'm not able to see all of the elements you've described. I'm going to go ahead and mark this as answer. – dst3p Sep 10 '19 at 13:39