The CreatorCon Call for Content is officially open! Get started here.

Update RITM "Comments" and Work note fields

Nancy8
Giga Contributor

I am trying   to update both "Comments" and "Work Note" my Requested Item when approver reject,   I used the following script in Run Script of my workflow:

var note ="This Retirement RITM is being rejected as the related change request was not approved" ;

var item = new GlideRecord('sc_req_item');

item.get(current.sys_id);

item.comments =note;

item.work_notes = note;

item.update();

However, both fields are not updated.   Event I did run the following script in Back-ground   script, but it still not works.    

var note ="This Retirement RITM is being rejected as the related change request was not approved" ;

var item = new GlideRecord('sc_req_item');

item.get('896ae660dbe5c7007e94ff621f961985');

//gs.print(item.comments);

item.comments =note;

item.work_notes = note;

item.update();

gs.print(item.comments);

gs.print(item.work_notes);

Can anyone help?

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

You either need to write a business rule on sysapproval_approver table or write a query in your run script to query the sysapproval_approver table to get the comments.



I would suggest adding a business rule on sysapproval_approver table.



Please mark this response as correct or helpful if it assisted you with your question.

Refer below link



Re: Reject Comments on RITM



Please mark this response as correct or helpful if it assisted you with your question.

RavindranKeshav
Giga Expert

Hi Nancy,



I tried your script on my instance it does work.. except for the print part.



var note ="pushed note2" ;


var item = new GlideRecord('sc_req_item');


item.addQuery('sys_id','aeed229047801200e0ef563dbb9a71c2');


item.query();


item.next();


//gs.print(item.description);


item.work_notes=note;


item.comments=note;


item.update();



gs.print(item.work_notes.getJournalEntry(-1)+'');


gs.print(item.comments.getJournalEntry(-1)+'');



I found some pointers here Attach work notes from task to RITM?



Hope it helps.



Regards


Ravindran


Jaspal Singh
Mega Patron
Mega Patron

Hi Nancy,



Since those are journal fields try using setJournalEntry('value to be passed').