Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Catalog item variables via rest API

brianlan25
Kilo Patron

We need to be able to get the variables of a catalog item based on tasks that are assigned to a specific group. I tried use the table api on the sc_task table and sc_req_item table hoping it would pull the variables but it did not. Is there a way for an external system to get the variables based on sc_task without having to make multiple calls to different tables?

1 ACCEPTED SOLUTION

Akshay Gupta2
Kilo Sage

Hi @brianlan25 

 

I understand that you need to pull catalog item variable data based on task. 

I found one thread, and I believe this can resolve your issue.

 

https://www.servicenow.com/community/developer-forum/access-catalog-task-variable-values-using-api/m...

 

Please mark this as helpful.

 

Thanks

Akshay

View solution in original post

2 REPLIES 2

monikaagraw
Tera Contributor

Extract Variables from Request Item:

var variablesGr = new GlideRecord('sc_item_option');
variablesGr.addQuery('request_item', reqItemId);
variablesGr.query();
while (variablesGr.next()) {
// Process each variable, variable name and value
var variableName = variablesGr.variable.name;
var variableValue = variablesGr.value;
// Store or process the variable data accordingly
}

then aggregate the variable data retrieved from each sc_req_item per your External System's requirements.

Akshay Gupta2
Kilo Sage

Hi @brianlan25 

 

I understand that you need to pull catalog item variable data based on task. 

I found one thread, and I believe this can resolve your issue.

 

https://www.servicenow.com/community/developer-forum/access-catalog-task-variable-values-using-api/m...

 

Please mark this as helpful.

 

Thanks

Akshay