Hi Get Catalog Variable Values Using Table APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 02:22 PM
Hi All,
Is there a way to get catalog variable values either from table 'sc_req_item' or 'sc_task' using OOB Table API?
I'm not looking for Scripted REST APIs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 02:27 PM
you can refer this https://www.servicenow.com/community/developer-forum/access-catalog-task-variable-values-using-api/m...
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards,
Ranjit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 02:55 PM
Thanks Ranjit.
Is there a way to get Multi Row Variable Set details as well using table APIs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 02:58 AM
Hi @Shiladitya Das ,
To retrieve the details of a Multi Row Variable Set using table APIs, you can use the 'sc_item_option_mtom' table. This table stores the relationship between the MRVS and its corresponding items. You can join this table with the 'sc_item_option' table to get the values of the MRVS questions. Here's an example script that retrieves the details of a MRVS for a specific request:
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', 'REQ0012345'); // replace with the number of the request
gr.query();
if (gr.next()) {
var mrvsSysId = gr.variables.mrvs_field_name.toString(); // replace with the sys_id of the MRVS field
var grMtom = new GlideRecord('sc_item_option_mtom');
grMtom.addQuery('request_item', gr.sys_id);
grMtom.addQuery('item_option_new', mrvsSysId);
grMtom.query();
while (grMtom.next()) {
var grItemOption = new GlideRecord('sc_item_option');
if (grItemOption.get(grMtom.item_option)) {
gs.info(grItemOption.value.toString()); // this is the value of the MRVS question
}
}
}
Thanks,
Ratnakar