From 184b1af29feadd0646a57470cc71cf47aae12da3 Mon Sep 17 00:00:00 2001 From: Soumyadeep Dutta <78016846+Soumyadeep10@users.noreply.github.com> Date: Thu, 9 Oct 2025 22:53:43 +0530 Subject: [PATCH 1/2] Create README.md --- .../README.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/README.md diff --git a/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/README.md b/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/README.md new file mode 100644 index 0000000000..6688d341be --- /dev/null +++ b/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/README.md @@ -0,0 +1,20 @@ +This is an Async Update Business rule written on the Requested Item table. +This code works as a comment synchronization mechanism. + +What the code does: +-Comment is added to the parent record(which in this case is a Requested Item) +-Creates an HTML link to the parent record using its number. +-Queries and finds all active SCTASKs associated with the Reuqested item. +-Loops through each SCTASK, adds the copied comment along with a link to the Requested Item. + +Let's explain with an example: + +RITM: RITM001001 +Task 1: SCTASK001001 +Task 2: SCTASK001002 +-User adds new comment into the RITM: 'This is a test comment.' +-Record link is created and stored inside a clickable RITM number. +-The RITM comment is updated on both the SCTASKs with the comment looking like: + + Updated comments on: [RITM001001] + This is a test comment. From 735ed1de724e1149e10c8a69e73c634c3ae4dbc8 Mon Sep 17 00:00:00 2001 From: Soumyadeep Dutta <78016846+Soumyadeep10@users.noreply.github.com> Date: Thu, 9 Oct 2025 22:57:11 +0530 Subject: [PATCH 2/2] Create synccommentfromritmtotask.js --- .../synccommentfromritmtotask.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/synccommentfromritmtotask.js diff --git a/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/synccommentfromritmtotask.js b/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/synccommentfromritmtotask.js new file mode 100644 index 0000000000..032d37e74b --- /dev/null +++ b/Server-Side Components/Business Rules/Synchronize RITM comments to Active tasks/synccommentfromritmtotask.js @@ -0,0 +1,14 @@ +(function executeRule(current, previous /*null when async*/ ) { + + var ritmLink = '[code]' + current.number.toString() + '[/code]'; + + var scTask = new GlideRecord('sc_task'); + scTask.addQuery('request_item', current.sys_id); + scTask.addActiveQuery(); + scTask.query(); + while (scTask.next()) { + scTask.comments = 'Updated comments on: ' + ritmLink + '\n' + current.comments.getJournalEntry(1); + scTask.update(); + } + +})(current, previous);