From eac1cfd04c26326b7b2ad4cb006048bc46de53f4 Mon Sep 17 00:00:00 2001 From: kishoretk92 Date: Fri, 31 Oct 2025 17:28:13 +0530 Subject: [PATCH 1/2] Create script.js --- .../Business Rules/Pass Attachments/script.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Server-Side Components/Business Rules/Pass Attachments/script.js diff --git a/Server-Side Components/Business Rules/Pass Attachments/script.js b/Server-Side Components/Business Rules/Pass Attachments/script.js new file mode 100644 index 0000000000..f3b6e61d8f --- /dev/null +++ b/Server-Side Components/Business Rules/Pass Attachments/script.js @@ -0,0 +1,24 @@ +//This script copies attachments from a source record in another table to the current record (likely a case or task). It ensures that attachments are preserved when creating or linking records across tables. + + +(function executeRule(current, previous /*null when async*/) { + +if(!current.source_record || !current.source_table) { + gs.info('No source record found for' + current.number); + return; +} +var sourceId= current.source_record.toString(); +var sourceTable = current.source_table.toString(); + +gs.info('coping attachments from' + sourceTable + '[' + sourceId +'] case' + current.number); + +try{ +var gsa = new GlideSysAttachment(); +var copiedCount = gsa.copy(sourceTable, sourceId, current.getTableName(), current.getUniqueValue()); + + +gs.info('Attachments copied from' + copiedCount +'attachment from' + sourceTable + ' to Case' + current.number); +}catch (e) { + gs.error('Attachment copied from case' +current.number + ': ' + e.message); +} +})(current, previous); From fa85a9cd8a94b0a5a9a561f8e697f5772943c34f Mon Sep 17 00:00:00 2001 From: kishoretk92 Date: Fri, 31 Oct 2025 17:28:51 +0530 Subject: [PATCH 2/2] Create read.md --- Server-Side Components/Business Rules/Pass Attachments/read.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Server-Side Components/Business Rules/Pass Attachments/read.md diff --git a/Server-Side Components/Business Rules/Pass Attachments/read.md b/Server-Side Components/Business Rules/Pass Attachments/read.md new file mode 100644 index 0000000000..9891a52f14 --- /dev/null +++ b/Server-Side Components/Business Rules/Pass Attachments/read.md @@ -0,0 +1,2 @@ +This script copies attachments from a source record in another table to the current record (likely a case or task). +It ensures that attachments are preserved when creating or linking records across tables.