Skip to content

Commit f91605c

Browse files
authored
Merge pull request #1982 from Soumyadeep10/Hacktober-2025-code_4th-Branch
Sync Comment from RITM to SCTASK
2 parents 24eff5f + 735ed1d commit f91605c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is an Async Update Business rule written on the Requested Item table.
2+
This code works as a comment synchronization mechanism.
3+
4+
What the code does:
5+
-Comment is added to the parent record(which in this case is a Requested Item)
6+
-Creates an HTML link to the parent record using its number.
7+
-Queries and finds all active SCTASKs associated with the Reuqested item.
8+
-Loops through each SCTASK, adds the copied comment along with a link to the Requested Item.
9+
10+
Let's explain with an example:
11+
12+
RITM: RITM001001
13+
Task 1: SCTASK001001
14+
Task 2: SCTASK001002
15+
-User adds new comment into the RITM: 'This is a test comment.'
16+
-Record link is created and stored inside a clickable RITM number.
17+
-The RITM comment is updated on both the SCTASKs with the comment looking like:
18+
19+
Updated comments on: [RITM001001]
20+
This is a test comment.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
var ritmLink = '[code]<a href="nav_to.do?uri=' + current.getLink() + '" target="_blank">' + current.number.toString() + '</a>[/code]';
4+
5+
var scTask = new GlideRecord('sc_task');
6+
scTask.addQuery('request_item', current.sys_id);
7+
scTask.addActiveQuery();
8+
scTask.query();
9+
while (scTask.next()) {
10+
scTask.comments = 'Updated comments on: ' + ritmLink + '\n' + current.comments.getJournalEntry(1);
11+
scTask.update();
12+
}
13+
14+
})(current, previous);

0 commit comments

Comments
 (0)