Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Querying the choices in a catalog item via REST

Mark205
Tera Contributor

Hi,

I have created a Catalog Item and added the variables I need to collect the relevant information. These are either Single Line Text or Select Box. The Select Box contains a static list of options the user can pick from. It is this list of options (or Choices) I need to query via REST. 

Using the API Explorer I have found the Item_Option_New table. This allows me to list all the variables associated with a particular Catalog Item. This includes the sys name, the question, read only flag etc. I was expecting (hoping) the see the choices here too, but they are not there. 

If I go to my Catalog Item and 'Try It', the options are correctly listed in the drop down. They are obviously stored somewhere and I was hoping someone here can point me in the right direction. As I mentioned, viewing them in the API Explorer would be ideal, then I can see the format of the REST call and use that in my application.

 

Thanks

1 ACCEPTED SOLUTION

Geoff_T
Mega Sage

Hello,

I think you're going to have to make 2 REST calls to get this data since the select box values are stored in the question_choice table.

 

First Query (via REST explorer) - to get the sys_id of Select Box Variables

tableName: item_option_new

sysparm_query: cat_item=a12037661bf13010c5da2f08b04bcb0f^type=5 (where cat_item is the sys_id of the catalog item you are querying and type 5 is to identify the Select Boxes)

sysparm_fields: question_text,name,sys_id

Results in a call like:

https://instance.service-now.com/api/now/table/item_option_new?sysparm_query=cat_item%3Da12037661bf13010c5da2f08b04bcb0f%5Etype%3D5&sysparm_fields=question_text%2Cname%2Csys_id&sysparm_limit=1

And returns:

{
  "result": [
    {
      "question_text": "SelectBox",
      "sys_id": "91f04a1787110110e0e263d73cbb352e",
      "name": "SelectBox"
    }
  ]
}

 

Second Query (via REST explorer) - to get the values of Select Box Variables:

tableName = question_choice

sysparm_query: question.sys_id=91f04a1787110110e0e263d73cbb352e (where sys_id here is the sys_id of SelectBox variable from first call)

sysparm_fields = text,value

Results in a call like:

https://instance.service-now.com/api/now/table/question_choice?sysparm_query=question.sys_id%3D91f04a1787110110e0e263d73cbb352e&sysparm_fields=text%2Cvalue&sysparm_limit=1

And returns:

{
  "result": [
    {
      "text": "Value2",
      "value": "Value2"
    }
  ]
}

 

I hope this helps.

Geoff

 

View solution in original post

2 REPLIES 2

Geoff_T
Mega Sage

Hello,

I think you're going to have to make 2 REST calls to get this data since the select box values are stored in the question_choice table.

 

First Query (via REST explorer) - to get the sys_id of Select Box Variables

tableName: item_option_new

sysparm_query: cat_item=a12037661bf13010c5da2f08b04bcb0f^type=5 (where cat_item is the sys_id of the catalog item you are querying and type 5 is to identify the Select Boxes)

sysparm_fields: question_text,name,sys_id

Results in a call like:

https://instance.service-now.com/api/now/table/item_option_new?sysparm_query=cat_item%3Da12037661bf13010c5da2f08b04bcb0f%5Etype%3D5&sysparm_fields=question_text%2Cname%2Csys_id&sysparm_limit=1

And returns:

{
  "result": [
    {
      "question_text": "SelectBox",
      "sys_id": "91f04a1787110110e0e263d73cbb352e",
      "name": "SelectBox"
    }
  ]
}

 

Second Query (via REST explorer) - to get the values of Select Box Variables:

tableName = question_choice

sysparm_query: question.sys_id=91f04a1787110110e0e263d73cbb352e (where sys_id here is the sys_id of SelectBox variable from first call)

sysparm_fields = text,value

Results in a call like:

https://instance.service-now.com/api/now/table/question_choice?sysparm_query=question.sys_id%3D91f04a1787110110e0e263d73cbb352e&sysparm_fields=text%2Cvalue&sysparm_limit=1

And returns:

{
  "result": [
    {
      "text": "Value2",
      "value": "Value2"
    }
  ]
}

 

I hope this helps.

Geoff

 

Mark205
Tera Contributor

Thats great, thanks Geoff. It was the question_choice table that was the missing piece of information for me. Your examples were very clear and even gave me some tips on how to refine my own queries. 

 

Thanks