- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 10:15 PM
Hi Folks
Any idea how to back up sys_attachment_doc records on a date range? The table list layout seems to time out every time it is being loaded, even with a simple script querying
var rec = new GlideRecord('sys_attachment_doc')
rec.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2015-10-02','00:24:00')@javascript:gs.dateGenerate('2015-10-02','00:54:00')");
rec.query();
if (rec.next()) {
gs.print(rec.sys_id + '\t' + rec.sys_created_on);
}
Any idea would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2015 10:58 PM
Hi George,
Thanks for getting back with the happy ending!
Consider marking your last post, mentioning export to xml, as the correct answer.
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 10:38 PM
Hi George,
Did you copy the encoded query from a list view?
Does the list view time out? For all the records - or a for a date range?
How many records are there in sys_attachment_doc?
This table as you may already know contains attachments broken into chunks - around 3 K per chunk I think.
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 10:41 PM
Hi Tony
Yes the date range is from 2nd Oct 00:24 to 2nd Oct 10:00, and the list times out every time.
Not sure of the number of records as I am not able to view the table by list view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 10:59 PM
Hi George,
Perhaps you could get a list of sys_attachment sys_ids for the data range you mention.
And then for each sys_attachment get the matching sys_attachment_doc chunks?
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 11:40 PM
Yep Yony, I have created a script to render the doc chunks
// sys_attachment table
var rec = new GlideRecord('sys_attachment')
rec.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2015-10-02','00:24:00')@javascript:gs.dateGenerate('2015-10-02','10:00:00')");
rec.query();
if (rec.next()) {
while (rec.next()) {
//bind sys_attachment
var att_doc = new GlideRecord('sys_attachment_doc')
gs.print(rec.sys_id + '\t' + rec.sys_created_on + '\t' + rec.file_name + '\t' + rec.size_bytes + '\t' + rec.table_name);
att_doc.addQuery('sys_attachment',rec.sys_id);
att_doc.query();
if (att_doc.next()) {
gs.print("attachment doc found");
while (att_doc.next()) {
gs.print(att_doc.sys_created_by + '\t' + att_doc.sys_created_on + '\t' + att_doc.sys_id + '\t' + att_doc.data + '\t' + att_doc.length + '\t' + att_doc.position);
}
}
}
}