Value of a catalog item

paradise623
Giga Expert

Hi All,

 

I'm looking to find the value of a catalog item so I can use it in a script. How do I find the value? 

for example: sc_cat_item (catalog item value/name)

3 REPLIES 3

Sumanth16
Kilo Patron

 

Hi  ,



If it is catalog item sys_id , type Maintain items(sc_cat_item) table and search with your catalog item name. And copy sys_id from list view (or) form.

If you want to  Get Catalog variables action and then use this

var shortDesc = fd_data._1__get_catalog_variables.role_s_selected.getDisplayValue();

return shortDesc;
 (or) 

if you are not using Get Catalog Variables Action then use this

var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var variableDisplayValue = rec.variables.role_s_selected.getDisplayValue();
return variableDisplayValue;


Please mark it as helpful (or) correct if it helps.



Thanks & Regards,

Sumanth Meda 

 

jMarshal
Mega Sage
Mega Sage

You're looking for the SysID. Go to your list of catalog items (sc_cat_item.list) and then right-click the catalog item in question and select "copy sysid". Paste into a notepad to inspect - it should be a 31 char hex value

Chaitali_Vale
Mega Sage
Mega Sage

Hello @paradise623 ,

 

To find out the catalog item value you must need to copy the sys_id of that catalog item. Please look into below example:

// Define the sys_id of the catalog item
var catalogItemId = 'paste catalog item sys_id';

 

// Create a new GlideRecord object for the sc_cat_item table
var catalogItemGR = new GlideRecord('sc_cat_item');

 

// Query the sc_cat_item table for the specified sys_id
catalogItemGR.addQuery('sys_id', catalogItemId);
catalogItemGR.query();

 

// Check if the catalog item record exists
if (catalogItemGR.next()) {
// Access fields of the catalog item record
var itemName = catalogItemGR.getValue('name');
var itemDescription = catalogItemGR.getValue('short_description');

 

// Get the information of catalog item by providing gs.info
gs.info('Catalog Item Name: ' + itemName);
gs.info('Catalog Item Description: ' + itemDescription);
} else {
gs.info('Catalog item not found.');
}

 

Please mark my solution correct or helpful,

Thanks

Chaitali.