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.

Need help in BR

nameisnani
Mega Sage

Hi Team , 

 

Need help in the below requirment 

 

Requirment - 

whenever work notes are updated in SCTASK, the same notes are automatically copied to the corresponding RITM work notes.

 

nameisnani_0-1756351029283.png

nameisnani_1-1756351061991.png

 

 

while testing 

 

nameisnani_2-1756351170842.png

So all the previous updates from Sctasks are reflected in RITM work notes

 

 

what was the mistake , what needs to be update 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

check this link on how it can be done and it helps in avoiding loop as well

Sync'ing RITM and SCTASK work notes \ additional comments  response from Sravani44

AnkurBawiskar_0-1756358080906.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Sandeep Rajput
Tera Patron
Tera Patron

@nameisnani What exactly is the question here? getJournalEntry(1 ) should give you the latest worknote from the SC task.

@Sandeep Rajput 

 

The problem is here  all the previous updates from Sctasks are reflected in RITM work notes

Ajay_Chavan
Kilo Sage
(function executeRule(current, previous) {
    
    var ritm = current.request_item.getRefRecord();
    
    if (ritm && ritm.isValid()) {
        
        // Get only the newly added work note entry
        var newNote = current.work_notes.getJournalEntry(1);
        
        if (newNote && newNote.trim() !== '') {
            // Create a formatted entry with SCTASK context
            var formattedNote = '[SCTASK: ' + current.number + '] ' + newNote;
            
            // Append to RITM work notes (this adds to existing notes)
            ritm.work_notes = formattedNote;
            ritm.update();
        }
    }
    
})(current, previous);
Glad I could help! If this solved your issue, please mark it as Helpful and Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

@Ajay_Chavan 

 

after updating the script same issue 

nameisnani_0-1756355123302.png

ritm 

nameisnani_1-1756355198275.png

 

@Ajay_Chavan @Sandeep Rajput 

 

hope you understand the problem here , could you please check above screesnhots .