We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Hi Get Catalog Variable Values Using Table APIs

Shiladitya Das
Tera Contributor

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.

3 REPLIES 3

Ranjit Nimbalka
Mega Sage

Hi @Shiladitya Das 

 

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 

Shiladitya Das
Tera Contributor

Thanks Ranjit.

Is there a way to get Multi Row Variable Set details as well using table APIs?

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