Help Updating Work Notes using a REST Message

Randy33
Tera Guru

I'm having issues with updating the work notes using a REST message.

Script Include:

request.setStringParameterNoEscape("notes", incGR.work_notes);
 
Any idea what I'm doing wrong?
 
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Randy33 

when you get the journal field value you get date/time and user details as well

use this to only include value from worknotes and not the date/time and user info

var workNotes = incGR.work_notes.getJournalEntry(1);
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
workNotes = workNotes.replace(dateRE, '');

request.setStringParameterNoEscape("notes", workNotes);

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

The work notes are showing as undefined.  Any idea why?

 

        var workNotes = incGR.workNotes.getJournalEntry(1);
        //var dateRE =  /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
        //workNotes = workNotes.replace(dateRE, '');

        request.setStringParameterNoEscape("sd", incGR.short_description);
        request.setStringParameterNoEscape("desc", incGR.description);
        request.setStringParameterNoEscape("rl_id", incGR.u_rl_number);
        request.setStringParameterNoEscape("notes", workNotes);

Hi @Randy33 ,

 

It's because u should write it this way

  var workNotes = incGR.work_notes.getJournalEntry(1);

 

U used workNotes hence the undefined.

 

The backend value for work notes is work_notes.

 

Thanks,

Danish

 

 

First, thank you however it is still not working.  

 

Here is what I have in the script include.  I'm also using a staging table (transform map) on the other side.

 

Randy33_0-1699895273683.png

Thoughts?