- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2019 11:25 PM
Hi,
I am trying to create catalog request using OOB service catalog REST API:
Here is the Request Body: all 3 variables are reference field.
Request submitted successfully but variables in RITM does not have any value.
All variables are reference but we cannot ask external system to pass sys_id. Also, display flag is true on those reference table and same value is passed through Rest API.
Anyone faced this issue before. Thank you so much in advance.
Thank You
Kiran Patil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2019 06:13 PM
Hi All,
Finally, I had to add small utility which can handle reference variables in REST API request for all catalog Items.
Here is script Include to run for BG:
var variables = {"user":"Abraham Lincoln","company":"Yahoo!","comments":"This is testing Text","requested_for":"System Administrator","needed_by":"Today"};
var itemId = "b5c3c1084f10330005ec00fe9310c7eb"; //myTestItem Catalog item
for(var key in variables)
{
if(variables.hasOwnProperty(key) && variables[key] && typeof(variables[key]) !== 'string')
variables[key]=variables[key].toString();
var varGr = new GlideRecord('item_option_new');
var qr = varGr.addQuery('cat_item', itemId);
var variableSet = new sn_sc.CatItem(itemId).getVariableSet();
if(variableSet.length > 0)
qr.addOrCondition("variable_set", variableSet);
varGr.addActiveQuery();
// varGr.addQuery('mandatory', true);
varGr.query();
// gs.print(variable[key] + ':' + varGr.reference);
while(varGr.next()) {
if(varGr.type == 8)
{
var objTable = new TableUtils(varGr.reference);
tableName = objTable.getAbsoluteBase();
gs.print(objTable.getAbsoluteBase());
if (tableName!='task') //Check if parent table is task
gQuery = 'name='+variables[key]; else gQuery = 'number='+variables[key];
var tb = new GlideRecord(tableName);
gs.print(varGr.reference);
tb.addQuery(gQuery);
tb.query();
if(tb.next())
{
variables[key]=tb.getValue('sys_id');
}
}else { variables[key]=variables[key]; }
}
}gs.print(JSON.stringify(variables));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2019 11:46 PM
try to give sysid of values
Please, remember to mark Correct or Helpful if you find my response useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2019 09:45 AM
It works with sys_id but we cannot ask external systems to send sys_id and we want to keep this generic catalog API where variables might change per catalog item.
I am checking for some generic approach.
Thank You

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2019 11:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2019 09:43 AM
Yes, I am using order_now OOB catalog API.