torsten-b
11/23/2016 - 8:18 AM

Attachment var current = new GlideRecord('incident'); current.get('9e0fce1f4f032200af7901f18110c771'); gs.print(current.number); var sa =

Attachment

var current = new GlideRecord('incident'); current.get('9e0fce1f4f032200af7901f18110c771'); gs.print(current.number);

var sa = new GlideRecord('sys_attachment'); sa.get('c9689dc94f132200af7901f18110c766'); copyAttachment(current, sa);

function copyAttachment(_targetRec, _attachmentRec) {
    var StringUtil = GlideStringUtil;
    var sa = new GlideSysAttachment();
    var newAttach = new Attachment();
    binData = sa.getBytes(_attachmentRec);
    var sysIdNewAttachment = newAttach.write(_targetRec.sys_class_name, _targetRec.sys_id, _attachmentRec.file_name, _attachmentRec.content_type, binData);
}