How to Update work notes using the fix script

Prathamesh Cha1
Tera Contributor

Hi Team,

 

I am trying to update the assigned to and with that I also want to update work notes, I tried following code but not working

 

var gr = new GlideRecord("sn_grc_issue");
gr.addEncodedQuery("assigned_to=65bfc314c3150e90765133001501311b");
gr.query();
gr.setValue("assigned_to", "59e619a2c3ad821cd0cd747dc0013148");
gr.setValue("work_notes","A VP left organization, i.e.,'Erika Sanchez', A new VP replaced the user, i.e., 'Alexis Sowa'");
gr.updateMultiple();
 
also tried gr.work_notes.setJournalEntry("")
but didn't work.
 
Please anyone can help me in this?
Thanks
9 REPLIES 9

anshul_goyal
Kilo Sage

Hi @Prathamesh Cha1 

Please try the below code and see if it works for you:

var gr = new GlideRecord("sn_grc_issue");
gr.addEncodedQuery("assigned_to=65bfc314c3150e90765133001501311b");
gr.query();
while (gr.next()) {
    gr.setValue("assigned_to", "59e619a2c3ad821cd0cd747dc0013148");
    gr.setValue("work_notes", "A VP left organization, i.e.,'Erika Sanchez', A new VP replaced the user, i.e., 'Alexis Sowa'");
    gr.updateMultiple();
}


Please mark my solution as Helpful and Accepted, if it works for you in any way!

Thanks

Hi @anshul_goyal ,

 

No it's not working, already tried.

@Prathamesh Cha1, I think you can use gr.update() instead of gr.updateMultiple() because we are using while loop.

Thanks

GouthamAnumolu
ServiceNow Employee
ServiceNow Employee

hi @Prathamesh Cha1  ,

 

Instead of using setValue to update worknotes , use dot-walking like below

 

gr.work_notes = "abc"

 

Since work notes is a journal fields , setValue might not work on those fields.