Move attachments to a different environment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2011 07:33 AM
Hi.
I have a project that will be going live later in the summer. My users would like to load data in the test environment and have me move it on go live day. This is fine, I can move lots of data, but the data involves attachments.
Is there a way to export attachments and import them in the production environment, without opening them one by one and manually attaching them?
in particular, we're loading software license records, and the attachments are the proof of purchase. Without the proofs, the records are just nothing.
Anyone know of a way to export attachments in bulk?
shris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2011 11:53 AM
Filter the list of records based on the records holding the attachments. Use the list header context menu to Export -> XML. The exported file will include the attachment data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2012 12:14 PM
This does not seem to work for images stored in knowledge articles.
When you add an image in a knowledge article, a html reference to the sys_attachment table is embedded in the html of the kb article (in the form:
Exporting the sys_attachment table does not do the trick either.
Does anyone know how to copy knowledge articles from one instance to another including the related attachments?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2012 12:40 PM
Hi.
What we finally ended up doing was this:
The sites prepared their attachments and posted them on an internal web server accessible to me. They prepared a spreadsheet containing the license information they wanted to upload, and one of the fields in the spreadsheet contained a URL to the attachment file.
I uploaded the spreadsheet to the production environment, then immediately exported those same records as XML files (to get the sys_ids). Then I parsed out the XML file using excel, and deleted everything except the sys_id, the URL for the attachment, and the ticket number (in case of errors).
We wrote ourselves a bulk uploader starting with the basic perl code provided in the SNC Wiki. We changed it quite a bit, but the ultimate idea was that the bulk uploader reads the spreadsheet, grabs the sys_id and the URL, retrieves the file from the URL to the local workstation (as a generic name so my machine didn't end up storing a bazillion files), and then formats the soap transmission to SNC in the format specified in the wiki.
It's a bit painful, this process, but it works and it's a heck of a lot faster doing hundreds of attachments this way than doing them by hand, even with drag-and-drop. It's also less prone to user error (dragging the wrong file to the record, etc.). The custom program outputs any problems to an error file, noting the sys_id of the record that had a problem. Since my input file had sys_id and the record number, I can send the record number to the requestor to double-check the URL.
The reason we wanted all the proofs of purchase in SNC directly is so we don't end up with broken links later on. If we just left the URL in the record and didn't attach the file, we'd be depending on that storage space forever--and stuff tends to move around to different server names as needs change, thus breaking links. This way, once we get all the attachments loaded, we can wipe the storage area clean and it won't matter, nothing will be lost.
For Tom, it's important to note that the attachment itself is in sys_attachment_doc, not sys_attachment. The sys_attachment table links the doc to the record, but that's it. And if you have table extension or rotation set up in your environment for attachments (as we do), it gets even messier.
For knowledge articles, you could probably export your articles to spreadsheet, parse out the data to obtain the URLs, and write yourselves a similar loader to grab the doc, save it locally, then attach it to the new article in the new location..
Kristina Hartman
Flextronics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2012 12:09 AM
I have found another (simpler) way to do it
It could simply be done by adding "update_synch=true" to the dictionary row of kb_knowledge and use update sets. However, this is not what I wanted to do (do not want knowledge articles to be put in update sets when they are created/updated)
What I did do:
- create a new table u_knowledge_export, added the fields I am interested in (number, text, short_description etcetera)
- changed the attributes field of the newly created table to "update_synch=true,synch_attachments=true"
- created a specific update set and set it as my current update set
- ran the following script in 'background script' using the .addQuery() function to select the knowledge articles I am interested in, in this sample selecting category 'test')
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('category', 'test');
gr.query();
while (gr.next()) {
var exp = new GlideRecord('u_knowledge_export');
exp.initialize();
exp.u_number = gr.number;
exp.u_short_description = gr.short_description;
exp.u_text = gr.text;
exp.u_meta = gr.meta;
var sys_id = exp.insert();
Packages.com.glide.ui.SysAttachment.copy('kb_knowledge', gr.sys_id, 'u_knowledge_export', sys_id);
}
After this, I have closed the update set & retrieved the updates set (and loaded it) on the system where I wanted the knowledge articles to be imported. By using a similar background script I copied the u_knowledge_export to the kb_knowledge.