Catalog item icon to display in ESC widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 04:38 PM
Hi everyone,
I'm hoping what I'm trying to do is possible. I'm trying to see if I can get the icon or picture from a catalog item to display in a custom widget I've build. Ideally, I need to get the icon/picture to display in my left TD, on the related forms widget I've built. Currently running a GlideRecord query against the related sc items table which displays on my cat item page.
Here's my server script:
(function () {
var cat_item = $sp.getParameter('sys_id');
data.catList = [];
// Query related items
var catalogRec = new GlideRecord('sc_2_sc');
catalogRec.addQuery('sc_cat_item', cat_item);
catalogRec.orderBy('related_sc_cat_item');
catalogRec.query();
while (catalogRec.next()) {
var temp = {};
temp.name = catalogRec.getDisplayValue('related_sc_cat_item');
temp.short_description = catalogRec.getDisplayValue('related_sc_cat_item.short_description');
temp.sys_id = catalogRec.getValue('related_sc_cat_item');
temp.catIcon = catalogRec.getDisplayValue('related_sc_cat_item.picture');
data.catList.push(temp);
}
})();
No matter what I try, I cannot get the icon or picture relating to the catalog item itself to display in the widget. Any help or guidance would be appreciated.
Thanks, Ed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 06:21 PM - edited ‎03-18-2024 06:21 PM
Hi,
How are you rendering it in your HTML?
The value you'd get back would be the sys_id of the sys_attachment record of the picture, plus something like: .iix
In your HTML, you'd want to consider rendering the image like:
<img src=/sys_attachment.do?sys_id=" + obj.catIcon + ">
I would perhaps just use getValue as well, using the method I listed, instead of getDisplayValue.
See if that helps?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 02:53 PM
Hi Allen,
Thanks for your advice. We managed to get it working, and it was the case of adjusting the HTML side of things.
This is what we used in the end:
<img ng-src="{{relatedItem.icon}}" src="{{relatedItem.icon}}" width="35px" height="35px">
Works really nicely! Thanks again for your advice!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 02:58 PM
Hi @Ed Hefford
Awesome! Glad you got it resolved.
If you don't mind and if you get time, please mark my reply above as "Accept Solution" if it helped guide you correctly.
Thanks for confirming and take care! 😀
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!