Access Catalog Task variable values using API

t_h1
Giga Contributor

I'm new to ServiceNow and assisting automation process. I can access catalog task information using SC_Task API end point but seems like Variables are store somewhere else. If I have a TASK000001 and need to retrieve value assigned to variable "X". How can I do that? Is there a table that links to Variables -> Values?

1 ACCEPTED SOLUTION

Hi,

It works in the REST API Explorer, you just have to use:

variables.field_name

Example of setup (you can use sc_task table as well, as mentioned above):

find_real_file.png

find_real_file.png

And on RITM itself:

find_real_file.png

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

You can query the sc_req_item (Requested Items) table or sc_task table, using the sys_id field value from the task record to then get the variables such as:

variables.variable_name

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Allen, this works via Angular JS / Widget scripting but from API. there is no field that returns for variables from sc_req_item table API end point. Is it possible that I need to query a different table when I'm accessing via API. 

 

Hi,

It works in the REST API Explorer, you just have to use:

variables.field_name

Example of setup (you can use sc_task table as well, as mentioned above):

find_real_file.png

find_real_file.png

And on RITM itself:

find_real_file.png

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ankur Bawiskar
Tera Patron
Tera Patron

@t_h 

approach mentioned by Allen will work.

Please use sc_task table instead of sc_req_item

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader