Copy Work Notes from SCTASK to RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:52 AM
I have two BR running from the SCTASK table to copy work notes/ additional comments to the parent RITM. However, none are working.
Below, is an example of one of the Business Rules for SCTASK>RITM.
- Table: SCTASK
- Before/ Update
- Condition: When Work Notes Changes
(function executeRule(current, previous /*null when async*/) {
if(current.work_notes.nil()){
return;
}
else {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.request_item);
gr.query();
while(gr.next()){
gr.work_notes = "Work Note added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>> " +current.work_notes;
gr.update();
}
}
})(current, previous);
Thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 07:10 AM
Hi @appstorm
you can write before business rule and use the below Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery('sys_id', current.document_id);
reqitem.query();
if (reqitem.next()) {
reqitem.comments = reqitem.comments + "\n" + current.comments.getJournalEntry(-1);
reqitem.update();
}
})(current, previous);
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 07:59 AM
Thank you for the suggestion! I tried the code, above - changing comments to work_notes. However, still nothing. Does this need to be a 'Before' Update or 'After'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 08:00 AM
Hi @appstorm
Can you try it with before insert or update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 08:36 AM
'Before' also doesn't work. I also double-checked no other business rules are running that may be conflicting with these two.