Transfer Attachments from parent to child when parent gets a new attachment

Kumar147
Tera Contributor

Hi,

I have a scenario that when a parent change record gets a new attachments from inbound, that record should be transferred to child record. can anyone help me to make this thing.

1 ACCEPTED SOLUTION

srjarmstrong
Giga Contributor

If you do go with copying the attachment, you'll be wanting to use the GlideSysAttachment API. The sample script in that API reference is very good to get you started:

var attachment = new GlideSysAttachment();
var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
var incGR = new GlideRecord('incident');
incGR.get(incidentSysID);

var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
gs.info('Copied attachments: ' + copiedAttachments);

Hope that helps.

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I would suggest to avoid copying the files as it would increase the attachment table size.

Please check this workaround which you can use

"Related Attachments" Related List

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

srjarmstrong
Giga Contributor

If you do go with copying the attachment, you'll be wanting to use the GlideSysAttachment API. The sample script in that API reference is very good to get you started:

var attachment = new GlideSysAttachment();
var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
var incGR = new GlideRecord('incident');
incGR.get(incidentSysID);

var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
gs.info('Copied attachments: ' + copiedAttachments);

Hope that helps.