List Field Names of a Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:04 AM
Hello,
If I know the sys_id of a Catalog Item (sc_cat_item table), how can I list all the fields of that item using a script?
Many of our service request forms are incompatible with Virtual Agent. What I want to do is create topics that can help users to fill out a form. They would select a field name they need help with, then VA would give them (hard coded) instructions on how to fill out that field.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:15 AM
Hi ,
Please refer to below thread:
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:16 AM
Hi,
Below will list all the variables for the catalog item
var gr = new GlideRecord('item_option_new');
gr.addEncodedQuery('cat_item=<cat item sys_id>^');
gr.query();
while(gr.next())
{
//do whatever
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:17 AM
Hi @Raj64
You could use the GlideRecord API to query the sc_cat_item table and get all the fields of a specific Catalog Item.
var sys_id = 'your_sys_id_here'; // replace with your sys_id
var gr = new GlideRecord('sc_cat_item');
if (gr.get(sys_id)) {
var allFields = gr.getFields();
while (allFields.hasNext()) {
var field = allFields.next();
gs.info(field.getName() + ' = ' + gr.getValue(field.getName()));
}
}
Mark Helpful/Solution 🙂
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:43 AM
Thanks Shaqeel, but I'm using a scoped application and getFields() doesn't work in scoped apps. 😞