Get Task/RITM details from REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 01:48 AM
Hello,
I'm trying to get details for a TASK/RITM that has variables such as check box, multiple selection buckets etc. through the REST API.
If I try to get just the Task/RITM it does not include the variables, even though they show up in the UI. I searched around a bit and found that I needed to use the "sc_item_option_mtom" and "sc_item_option" tables to get the details. I tried to get the details for one particular Request but see that a few of the results I get from sc_item_option table are just blank where the item_option_new and value should be and do not include
How can I get all the values of the variables through the REST API?
Thanks,
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 02:16 AM
Snapshots please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 02:29 AM
Hi Surendra,
This is the call I make to get the results from the sc_item_option_mtom table:
/api/now/table/sc_item_option_mtom?sysparm_limit=10&sysparm_display_value=true&sysparm_exclude_reference_link=True&sysparm_query=request_item%3D<request item sys_id>&sysparm_fields=sc_item_option
The result of the call is:
{"result": [{"sc_item_option": "<sys_id1>"},
{"sc_item_option": "<sys_id2>"},
.
.
.
]}
I then use one of these to get the value from the sc_item_options table with the following call:
api/now/table/sc_item_option?sysparm_limit=10&sysparm_display_value=True&sysparm_exclude_reference_link=True&sysparm_query=sys_id%3D<sys_id for sc_item_option>&sysparm_fields=item_option_new,value
The following is the result I get:
{"result": [{"item_option_new": "","value": "undefined"}]}
Thanks,
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 02:44 AM
Hi karanpreet,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 02:55 AM
Hi Priyanka,
That's the article I followed to get this far but I'm not getting the required details. My previous reply contains the issue and shows that there's no Data for some of the options being reported back.
Thanks for the article though.
Regards,
Karan
You can use the REST API to pull data from any table, so it's just a matter of knowing where the data is and how to find what's related to your Requested Items (RITM). Variables are stored in their own table, not as a field on the RITM record, so you need to decipher the relationship before you can try to query for what you want.
variables are actually called "Options" once they have a value assigned and are stored in the Options table [sc_item_option]. The table called "Variables" ([item_option_new]) only stores the definition of that variable (i.e., it's type, associated question, hint, etc.). So the Options table is where you want to look at for your actual values.
To get to the Options you are looking for, you will need to look at a Many-to-Many table [sc_item_option_mtom] relating your Requested Items to their Options. So if you have the sys_id of your RITM handy:
If you need help querying with the REST API, please check the wiki article here:
Table API - ServiceNow Wiki
https://developer.servicenow.com/app.do#!/rest_api_doc?v=jakarta&id=r_TableAPI-PUT
Make it Correct or helpful if it works.
Warm Regards,
Priyanka
www.dxsherpa.com