Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SCTASK work notes copy into other SCTASKs within the same RITM

patrykprejs
Tera Contributor

Hi all,

 

I have an issue where currently any work notes put in a SCTASK copy across to any other task within the same RITM, the Tasks could be closed already but the update made in 1 of them will copy over to all the other SCTASKs in that specific Request.

 

This has never been an issue prior but as of the last 6 months this has been noticed, I am not sure what may have changed.

 

Is there anything I could do for this not to happen? I am thinking that it may need a new BR but I am still learning scripting and would appreciate any help.

 

The attached screenshot just shows the two comments I left, these two comments will copy across to the RITM which is fine but also to all the other TASK within.

 

Thank you.

2 REPLIES 2

SanjivMeher
Mega Patron
Mega Patron

Check the Business Rule on SCTASK. Someone might have added a code to copy the notes to other tasks.


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

 

The only code I could find in the SCTASK business rules to do with the Work Notes would be the below this is to Copy work notes to RITM:

 

(function executeRule(current, previous /*null when async*/) {

    var compare,task_worknote2,task_worknote,ritm_worknote2,ritm_worknote;
    task_worknote = current.work_notes.getJournalEntry(1);
   
    //Remove timestamp and name from additional worknote
    var regex= new RegExp('\n');
    var i = task_worknote.search(regex);
    if (i>0)
    {
    task_worknote2 = task_worknote.substring(i+1, task_worknote.length);
    }
   
    var ritm_gr = new GlideRecord('sc_req_item');
    ritm_gr.addQuery('sys_id', current.parent);
    ritm_gr.query();
   
    if(ritm_gr.next())
    {
    ritm_worknote =ritm_gr.work_notes.getJournalEntry(1);
   
    //Remove timestamp and name from additional worknote
    var i1 = ritm_worknote.search(regex);
    if(i1 > 0)
    {
    ritm_worknote2 = ritm_worknote.substring(i1+1, ritm_worknote.length);
    }
    compare = task_worknote2.indexOf(ritm_worknote2);
   
    if(compare == -1) // If No match found
    {
    ritm_gr.work_notes = task_worknote2.trim();
    ritm_gr.update();
    }
    }
   
    })(current, previous);
 
 
I don't think it has any reference as this is the Business Rule for the SCTASKs to also get the comment, is there anything else I could check or do?