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

Swapna Abburi
Mega Sage
Mega Sage

@Akshaya R 

I think you don't need to query sc_item_option_mtom table. You can directly use "variables.<variable name>" to get the value of RITM variables.

Hi Swapna,

 

Just tried the way you suggested as below. "Department" is one of the variables of the RITM and sys_id corresponds to the RITM.

https://<<instance>>.service-now.com/api/now/table/sc_req_item?sysparm_query=sys_id%3Dcf8e87f61b13dd...

 

The response was still empty.

@Swapna Abburi  - Attaching the URI as an image for more clarity.

AkshayaR_0-1669637202094.png

 

Swapna Abburi
Mega Sage
Mega Sage

The API looks fine. Is Department variable present on the Requested Item in variables section? Please share the screenshot of the variable.