How to attach some file in format excel or PDF on many Asset with a load file or other solution
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2025 11:50 AM
In ServiceNow Asset table we have many file to attach on many Asset Entry. We don't want to do it manually. Do we have a solution to do all attachement in 'one shot'
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2025 12:25 PM
Hello @mathieucoss ,
You can check out the out of the box function.
copy(String sourceTable, String sourceID, String targetTable, String targetID)
Copies attachments from the source record to the target record.
First attach a file to one record.
GlideRecord the records to which it should be attached, and write a for loop and add this copy function in it.
Example:
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);
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.