How to move the approval /rejection status to work notes in ritm

jobin1
Tera Expert

Hi All

 

In ritm form is some one is approved or rejected the approval then the same message has to be updated in work notes as well, How we can achieve this?

find_real_file.png

1 ACCEPTED SOLUTION

@jobin 

No No. Please see my updated comment . I am posting it again with details which you need to try:

BR Details:

Table name: sysapproval_approver

When: After Update

Condition: Comments Changes

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord('sc_req_item');
	gr.addQuery('sys_id',current.sysapproval);
	gr.query();
	if(gr.next()){
		gr.work_notes = current.comments.getJournalEntry(1);
		gr.update();
	}

})(current, previous);

BR:

find_real_file.png

Result:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

11 REPLIES 11

jobin1
Tera Expert

@Ankur Bawiskar Any idea?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you saying if someone rejects approval and adds some comments; then that should be copied to RITM?

if yes then you can do this

1) after update BR on sysapproval_approver

2) condition: current.source_table == 'sc_req_item' && current.state == 'rejected'

Script:

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sysapproval);

ritm.comments = current.comments;

ritm.update();

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 

@Ankur Bawiskar 

 

Its not working I have rejected the approvals in ritm and its not updating anything in work notes

 

find_real_file.png

 

find_real_file.png

 

I have rejected the approval that's why it is showing as empty.

find_real_file.png

Hi,

update as this

I hope you are giving comments when you are rejecting the approval record

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sysapproval);

ritm.comments = current.comments.getJournalEntry(1);

ritm.update();

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader