File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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 ) ;
You can’t perform that action at this time.
0 commit comments