Is there any way to move images/icon of service catalog from instance to another ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 01:34 AM
Hi,
I tried moving images of my catalog item from one instance to another using update set but its not working. I checked admin override of ACL with function "getSCAttachmentReadAnswer" and I was able to see it in sys_attachment table. Somehow I captured it also in update set(by selecting items in sys_attachment table and selected Create application file) but after committing update set in my test instance , it says file is empty.
Attached screenshot how it empty file got added in my catalog.
Can anyone help me out how we can move images and icon of catalog item from one instance to another as I have more that 175 catalogs which needs to be moved to another instance??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2016 08:41 AM
Hi Rev -
If memory serves me right (and I have a bad memory!), there were three tables involved. These all work together. Just grabbing some information from our SN ticket:
- db_image - Per SN, contains metadata for the image - I believe these are images that were uploaded to articles, rather than drag-and-drop.
- sys_attachment - Per SN, contains metadata for that db_image. Look for the target name of ZZ_YYdb_image. You might need to adjust an ACL to see this.
- sys_attachment_doc - Per SN, contains all the base64 encoded segments of the actual image file.
Since our clone excluded the sys_attachment table etc. due to that pesky, auto-filled "Exclude large attachment data" checkbox, first we went back to the original, functional instance:
- From the original instance, we imported chunks from db_images. Images appeared in this table in the new instance, but were still broken in kb and catalog items. If your db_images table in the new instance already has everything, you may not need to check this, as long as the sys_ids are identical. Check sys_attachment too, and make sure it matches the original instance.
- From the original instance, imported from the sys_attachment_doc table - we had to do a filtered search on that table to break it down into manageable, bite-size XML downloads. It was rather annoying, since I didn't know which records on the sys_attachment_doc table related to the missing images. Once we imported the XMLs to our new instance, however, we were able to view the images within the articles/items. Image below is an explanation of how we dot-walked to the file type. Even though the field doesn't appear as an option when you try to configure the sys_attachment_doc list, you can still dot-walk the filter to the the sys_attachment file name and just trust the results. Things still aren't 100% but they're better than a poke in the eye. In case the image is wonky, the filter on the sys_attachment_doc table was:
All>Sys attachment.File name contains gif
Rinse and repeat for png, jpeg, jpg, pdf, etc.
Hope that helps - and hope my memory caught everything!
Kim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 09:20 PM
I know i am late responding to this post but just in case anyone else is still looking for moving images associated with Hardware Catalog items(or any catalog item) with an update set then it can be done using the script below.
Essentially the steps are:
- Query the sysId of the catalog items for which you want images captured in an update set
- Search sys_attachment table with the sysId of catalog item. Note that images associated with catalog items are stored in sys_attachments and sys_attachment_doc table
- Save the attachment record in update set.
//Query for the CMDB Model record
var grModel = new GlideRecord('pc_hardware_cat_item');
grModel.addEncodedQuery('active=true^sys_class_name=pc_hardware_cat_item');
grModel.query();
while (grModel.next()) {
//gs.log(grModel.sys_id);
queryAttachments(grModel);
}
function queryAttachments(modelGR) {
//Query for the record
var rec = new GlideRecord('sys_attachment');
rec.addQuery('table_sys_id', modelGR.sys_id);
rec.query();
while (rec.next()) {
gs.log(rec.sys_id);
addAttachmentToUpdateSet(rec);
}
}
function addAttachmentToUpdateSet(attachmentGR) {
var um = new GlideUpdateManager2();
um.saveRecord(attachmentGR);
var attdoc = new GlideRecord('sys_attachment_doc');
attdoc.addQuery('sys_attachment', attachmentGR.sys_id);
attdoc.orderBy('position');
attdoc.query();
while(attdoc.next()){
um.saveRecord(attdoc);
}
}
Once you move the update set from source instance to destination instance, dont forget to clear server cache and your browser cache before retesting.
Please mark this helpful/correct if you find the information useful.