From c279a5c34b05389fd9ab03c806c2a63a203100cb Mon Sep 17 00:00:00 2001 From: Kart-19 <92006241+Kart-19@users.noreply.github.com> Date: Sun, 19 Oct 2025 15:55:54 +0530 Subject: [PATCH] Cascade Problem worknotes to Origin task --- .../Readme.md | 8 ++++++ .../cascade.js | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/Readme.md create mode 100644 Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/cascade.js diff --git a/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/Readme.md b/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/Readme.md new file mode 100644 index 0000000000..0c4ab79bf5 --- /dev/null +++ b/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/Readme.md @@ -0,0 +1,8 @@ +Cascade Problem Worknotes to Origin Task + +Script Type : Business Rule Trigger: after update Table: problem Condition: Work Notes Changes + +Goal : To Notify to that particular record(ticket) when Problem record has updated the worknotes. + +Walk through of code : +So when there is update/change in the worknotes of a problem record this Business rule will cascade the worknotes to that attached Origin Task record so that it will be update in that particular record as well. In this some validation have been used to avoid unnecessary data cascade, this Business will work only for the open problem, mean this it will exclude the Closed & Resolved State Problem which have been already addressed. So once the worknote is posted it will updated respectively to the origin task. diff --git a/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/cascade.js b/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/cascade.js new file mode 100644 index 0000000000..5791dcf710 --- /dev/null +++ b/Server-Side Components/Business Rules/Cascade Problem Worknote to Origin Task/cascade.js @@ -0,0 +1,28 @@ +(function executeRule(current, previous /*null when async*/ ) { + + /* + Input + 1. Worknotes changes in Problem + + Validation & Check + Exclusion of Closed & Resolved State Problems + + Output + Updatation of Origin Task record worknotes + + */ + + // Getting the Problem current worknotes + var workNotes = ''; + if (current.work_notes.changes() && (current.state != 107 && current.state != 106)) { + workNotes = current.work_notes.getJournalEntry(1).match(/\n.*/gm).join(" "); + + // To update in the Origin Task field directyl by using the getRefRecord() mehtod. + var inc_rec = current.first_reported_by_task.getRefRecord(); + inc_rec.work_notes = "Update on : " + current.number + workNotes; + inc_rec.update(); + } + + + +})(current, previous); \ No newline at end of file