From a2a34a23336313041b68d614e19daa611c3e86e7 Mon Sep 17 00:00:00 2001 From: Trupti Ahire Date: Mon, 6 Oct 2025 16:03:03 +0530 Subject: [PATCH] Copy record attachment to Email Client --- .../CopyAttachmentToEmailClient.js.js | 18 ++++++++++++++++++ .../ReadMe.md | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 Server-Side Components/Script Includes/Copy record Attachment to Email Client/CopyAttachmentToEmailClient.js.js create mode 100644 Server-Side Components/Script Includes/Copy record Attachment to Email Client/ReadMe.md diff --git a/Server-Side Components/Script Includes/Copy record Attachment to Email Client/CopyAttachmentToEmailClient.js.js b/Server-Side Components/Script Includes/Copy record Attachment to Email Client/CopyAttachmentToEmailClient.js.js new file mode 100644 index 0000000000..0a34107334 --- /dev/null +++ b/Server-Side Components/Script Includes/Copy record Attachment to Email Client/CopyAttachmentToEmailClient.js.js @@ -0,0 +1,18 @@ +var CopyAttachmentToEmailClient = Class.create(); + +CopyAttachmentToEmailClient.prototype = { + initialize: function() { + }, + + copyAttachment: function(sourceTable, sourceSysId, targetSysId) { + var attachmentRecord = new GlideRecord('sys_attachment'); + attachmentRecord.addQuery('table_sys_id', sourceSysId); + attachmentRecord.query(); + if (attachmentRecord.next()){ + GlideSysAttachment.copy(sourceTable, sourceSysId, 'sys_email', targetSysId); + } + + } + + type: 'CopyAttachmentToEmailClient' +}; \ No newline at end of file diff --git a/Server-Side Components/Script Includes/Copy record Attachment to Email Client/ReadMe.md b/Server-Side Components/Script Includes/Copy record Attachment to Email Client/ReadMe.md new file mode 100644 index 0000000000..41111f3c0c --- /dev/null +++ b/Server-Side Components/Script Includes/Copy record Attachment to Email Client/ReadMe.md @@ -0,0 +1,6 @@ +Use Case: If user click on Compose Email, All the attachment of corresponding record should be attach automatically to email client + + + +`new global.CopyAttachmentToEmailClient().copyAttachment('incident', current.instance, current.sys\_id);` +