Attachment UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2008 09:40 AM
I had a request to create UI action for attachments instead of using the lil paper clip icon.
I just grabbed the onclick script (using firebug, firebug is cool!!)
saveAttachment('incident', '');
and created a new client UI action with the same onclick code on the incident table.
Nothing special, but thought some of you could use that to truly make something cool...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 03:46 PM
Karthik,
Are you looking to save one attachment to multiple records? Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 08:33 PM
Yes, exactly, save attachment to multiple selected records..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 03:11 AM
in that case, you would need to change the onClick to a custom function:
onclick: doThis()
then create that function in your script area:
function doThis () {
//first turn the getChecked into an array
var csv = g_list.getChecked();
var array = csv.split(",");
//then iterate through the array adding the attachment to each record
for(x=0; x<array.length; x++) {
saveAttachment('incident', array[x]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 03:22 AM
Thanks much for the response!!
I have tried this and it works for one record only, even if i select multiple records.
for ex, 3 records i selected, and only one record gets the attachment and not all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 03:48 AM
then it is probably attaching it to the first record in the list. In that case you can adjust the function to the following:
onclick: doThis()
then create that function in your script area:
function doThis () {
//first turn the getChecked into an array
var csv = g_list.getChecked();
var array = csv.split(",");
//attach to first elemment in the array
saveAttachment('incident', array[0]);
//find the new attachment
var attGR = new GlideRecord('sys_attachment');
attGR.addQuery('table_sys_id', array[0]);
attGR.orderByDesc('sys_created_on');
attGR.query();
if (attGR.next()) {
var originalID = attGR.sys_id;
//then iterate through the remainder of the array copying the attachment to each record
for(x=1; x<array.length; x++) {
attGR.table_sys_id = array[x];
var newID = attGR.insert();
var attDocGR = new GlideRecord('sys_attachment_doc');
attDocGR.addQuery('sys_attachment', originalID);
attDocGR.query();
while (attDocGR.next()) {
attDocGR.sys_attachment = newID;
attDocGR.insert();
}
}
}
}
Depending on how many records are selected and the size of the file, you might be better off doing this in a script include and passing the array over after the first attachment. How this helps