Update problem work notes using a fix script

Sharon Williams
Tera Contributor

Hello, I created a fix script (see below) to update the state and work notes of certain problem records.  The fix script is not completely working.  The state is getting updated, however there is no update to the work notes after I run the fix script.  Can someone help me with this?  Thanks...

 

var grProb = new GlideRecord('problem');
grProb.addEncodedQuery('stateNOT IN101,102,103,104,106,107^;
grProb.query();
while (grProb.next()) {
     grProb.state = 107;
     grProb.setValue.work_note = "This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.";
     grProb.update();
}

6 REPLIES 6

Hi Prateek.   I tried the syntax that you suggested and it did not work. Do I have to do some type of insert to update the work note with the new text?

Thanks Prateek.  I had to update the code to:

grProb.work_notes.setJournalEntry('This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.');