Fetching "Variables" values in REST API

s_gatade
Kilo Contributor

Dear all,

Our ServiceNOW Setup has some custom variables defined for Request Items. e.g. "Requested for:". Is it possible to get the values for these parameters defined under Variables via REST API Dot Walking or any other REST option?

Thanks in advance!

S. Gatade

7 REPLIES 7

banusan
Mega Contributor

Try this. This helped me a lot.


That is a wonderful article! Thanks a lot to put it here. 🙂

Nick Parsons
Mega Sage

In your REST API call, you can add variables.VAR_NAME to your sysparm_fields list, where VAR_NAME is a variable name you want to add, eg (here the %2C represents a comma , in an encoded URL):

https://your_instance.service-now.com/api/now/table/sc_req_item?sysparm_fields=number%2Cstate%2Cvariables.VAR_NAME

This will give you back, the fields number, state and the variable VAR_NAME in the result. Note that the result won't include variables.var_name if the record doesn't have this variable associated with it. For reference fields/variables, you can look at updating the sysparm_display_value field to true or all to avoid showing just the sys_id. The above will work for both OoTB tables and custom tables.