Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get variable values from RITM using REST API

Akshaya R
Tera Contributor

Hi All,

 

I am trying to read the variable values from a requested item using REST API. I queried the table "sc_item_option_mtom" with the below context.

sc_item_option_mtom.request_item=<<sys_Id of the corresponding RITM>>

 

The output response from postman looked something like below:

{

   "result": [

                  {},

                  {},

                  {},

                  {},

                  {}

                  ]

}

 

What does this response mean? What is the mistake that am making here? I would like to capture the values of the custom variables in a request item. 

 

Thank you!

2 ACCEPTED SOLUTIONS

Hope you are using name of the variable?

SwapnaAbburi_0-1669708889339.png

 

View solution in original post

Please update "sysparm_display_value" to true in REST API Explorer. 

 

Note: Table level API is ok if you are planning to use this API for only one catalog item with limited fields/variables to retreive.

If you configure a scripted rest API, you can leverage it for all request items which is a more stable and configurable solution.

SwapnaAbburi_0-1669722080047.png

 

View solution in original post

10 REPLIES 10

Hi Swapna,

 

Attaching the snapshot of variables below:

AkshayaR_0-1669707242807.png

 

Any help would be appreciated.

 

Thanks,

Akshaya

 

Hope you are using name of the variable?

SwapnaAbburi_0-1669708889339.png

 

Hi Swapna, 

 

Thanks for your guidance! This did work! Thank you so much.

 

One last question. One of the variables as shown below, is a list input field.

variables.compound only fetches the sys_id of the chosen values whereas couldn't retrieve the actual name of the selected values. Could you please provide your inputs here?

 

AkshayaR_0-1669713903282.png

(Had to hide the values partially due to confidential reasons.)

 

Regards,

Akshaya

Please update "sysparm_display_value" to true in REST API Explorer. 

 

Note: Table level API is ok if you are planning to use this API for only one catalog item with limited fields/variables to retreive.

If you configure a scripted rest API, you can leverage it for all request items which is a more stable and configurable solution.

SwapnaAbburi_0-1669722080047.png

 

Yes this worked too! Thanks a lot again! 

I am a beginner with Snow APIs and your support was really helpful.

 

And about the table/scripted API, at the moment we are just looking for a single item retrieval by using the RITM sys_id. Thank you for the suggestion. I will keep in mind for future requests.

 

Regards,

Akshaya