Service Task Variables vis Rest API

Alex Woolridge
Kilo Expert

Good Morning, We are trying to find a Rest API that will link the "sc_task" or the "sc_req_item" tables to the variables and the answers to these so we can create a report in PowerBI. I believe the table is "sc_item_option_mtom" but I am unable to find a way to link this to the correct table to link all things together. We need to pull out 1 particular field in the variables list and link to the request so we have all details.

1 ACCEPTED SOLUTION

Morning, 

This didnt work as expected and I kept getting a failure but I found this website "https://snprotips.com/blog/2016/7/15/scripted-rest-apis-in-servicenow-how-to-retrieve-catalog-item-variables" from a few years ago and following this process end to end working. Thanks for your help and pointing me in the right direction

View solution in original post

7 REPLIES 7

BALAJI40
Mega Sage

Hi Alex,

Currently, We don't have one direct link to get all these details because variable editor information stores in different tables.

Variables information stores in the sc_item_option_mtom and answers information stores in "sc_item_option"

 

Hence, the easiest way is to create your own scripted REST API, and in the script create a glide record on the sc_item_option_mtom table and create the output response as per your requirement.

 

Notes: From sc_item_option_mtom you can get the answers by dot walking through the dependent item (sc_item_option) field.

palanikumar
Mega Sage

Hi Alex,

In OOB API you have to mention the variable names you want. You can follow the below steps:

1) Goto Rest API Explorer

2) In table name select sc_task

3) In sysparm_fields enter the coma separated list of fields you want. For variables prefix with  variable. eg(number,short_description,variables.variable1,variables.variable2,variables.variable3)

Note: You can type the value in sysparm_fields. If you use pencil icon, you will not find option to choose variable

find_real_file.png

4) Send request

5) You will see the URL with parameters in Request section. You can use this in Power BI

Thank you,

Palani

Thank you,
Palani

Thanks, this really helped me out today 🙂