Sync'ing RITM and SCTASK work notes \ additional comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 03:16 PM
Hello all,
Currently we are attempting to synchronize the additional comments and work notes between RITM and its associated TASKs (and vise versa). Essentially, if a comment or work note is made on a SCTASK, it needs to copy that to the RITMs comments or work notes (or both and again, vise versa)
Below is what we have,
the RITM Business Rule:
(function executeRule(current, previous /*null when async*/ ) {
var taskGR = new GlideRecord('sc_task');
taskGR.addEncodedQuery('request_item=' + current.getUniqueValue());
taskGR.query();
//gs.info("BR is active");
while (taskGR.next()) {
if ((taskGR.work_notes.getJournalEntry(1) != current.work_notes.getJournalEntry(1)) && (taskGR.comments.getJournalEntry(1) != current.comments.getJournalEntry(1))) {
taskGR.comments = current.comments;
taskGR.work_notes = current.work_notes;
taskGR.update();
}
}
})(current, previous);
the SCTASK Business Rule:
(function executeRule(current, previous /*null when async*/ ) {
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.addEncodedQuery('sys_id=' + current.request_item.sys_id);
ritmGR.query();
//gs.info("BR is active");
while (ritmGR.next()) {
if ((ritmGR.work_notes.getJournalEntry(1) != current.work_notes.getJournalEntry(1)) && (ritmGR.comments.getJournalEntry(1) != current.comments.getJournalEntry(1))) {
ritmGR.comments = current.comments;
ritmGR.work_notes = current.work_notes;
ritmGR.update();
}
}
})(current, previous);
We wanted to avoid an infinite loop situation so we have the if statements there to prevent that, however, for example, if I make a comment on the task, it will update the ritm, which then updates the task. This leaves the task with a duplicate comment, and I am wondering if anyone has a solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2021 08:24 PM
Can you please help me with a script to get a similar sync between REQ and RITM?
(eventually, I'm leading this from the task all the way to the case)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 07:44 AM
Hi @Sravani44 , how can we apply the same logic when we have multiple child tasks for one parent task? In that scenario, this logic is not working as expected.
How can I modify the script to achieve the desired behavior and stop the loop in this scenario.