ServiceNOW not able to update work_notes through postman

Laxmi18
Tera Expert

I'm trying to update an incident's work_notes from POSTMAN with the below details, but it's not updating them. However I have referred the ServiceNOW documentation and trying the REST call the same way but still data is not getting updated.

Other fields like comments, description are getting updated or added, but only work_notes is not getting added.

We are using rest method

 

We have done mapping :

Laxmi18_0-1704868913833.png

 

 

below is the script

 

if (stat == "Pending" && source.u_action.toString() == "inc_state_pending") {
           
            if (source.pending_reason == '') {
            error = true;
            error_message = 'Missing mandatory fields for Insert';
        }
       
                if (source.pending_reason == 'User Response' || source.pending_reason == 'Change Request' || source.pending_reason == 'Vendor Response')
            {
               target.pending_reason = source.pending_reason;
                target.state = '4';
                target.work_notes = source.u_work_notes;
               
            }          
           
            else {
               
                error = true;
            error_message = 'Invalid Pending  Reason';
               

            }          
           
        }

 

 

1 ACCEPTED SOLUTION

piyushsain
Tera Guru
Tera Guru

Hi,

If the source field is also of type work note use script 

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

target.work_notes = workNotes;
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

View solution in original post

3 REPLIES 3

Abbas_5
Tera Sage
Tera Sage

Hello @Laxmi18,
Please refer to the below link:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0957567

 

If it is helpful, please mark it as helpful and accept the solution.

Thanks & Regards,
Abbas Shaik

piyushsain
Tera Guru
Tera Guru

Hi,

If the source field is also of type work note use script 

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

target.work_notes = workNotes;
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

Addy22
Tera Guru

Hi @Laxmi18 

 

You can try this

target.work_notes.setJournalEntry('source.work_notes)