How to get variables and variable values via a REST call?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 08:24 AM
Hello,
We are making a REST call that filters certain tasks and then for each one of them we run a workflow in another tool. So far, so good.
The problem is that the call to "/api/now/table/sc_task?state=1&short_description=****" does not bring the value of the variables in that particular task.
I assume that a secondary call is needed - and for as much as I know it has to be to sc_item_option_mtom (where ritm variables are stored). Even if we make this call - the answer does contain the info needed, and a third call would be needed for each variable to sc_item_option. Not to mention that all is in sys_id format (I don't get the actual question display value, but its sys_id)
Is there a way to obtain the values of the variables without making these many calls? I would be satisfied with the original call - which gives me the task number or the ritm number, and a second call where I can get the variables and their values. Can this be done?
Thank you
Nick
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 08:35 AM
Hi,
you will have to do 2 API calls
1) get RITM for your SC Task
2) Then query with variables.xxxx=YYYYYY for those RITMs
OR
You need to create Scripted REST API and then get the record matching the query
refer below link
Scripted REST APIs & Retrieving RITM Variables via SRAPI
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 09:19 AM
Thank you for marking my response as helpful.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 11:15 PM
Hi Ankur,
Can you explain a little more #2. Towards what table should we make that call and is xxxx = name variable and what is yyyy?
Regards,
Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 11:28 PM
Hi,
just checked this link and it mentions you can get the variables from sc_task table API
We can directly add the variables.<variablename> in the link.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader