How to copy a field changes on Approval table into a case table work notes when a case is approved ?

Nagurbee1
Tera Contributor

Hello Everyone

I am trying to update a case record work notes with approver name who has approved / rejected a case.

When a case is rejected, rejection comments needs to added in the work notes of a case.

Could any one please help me to achieve it ? (please refer attached screenshot)

 

 

Thanks in advance

Nagurbi

2 ACCEPTED SOLUTIONS

here is a sample, you can add more conditions and refine it as needed

 

AnuragTripathi_2-1729863955518.png

 

 

AnuragTripathi_0-1729863883654.png

 

 

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

	var grec = new GlideRecord("change_request");
	grec.addQuery("sys_id", current.sysapproval);
	grec.query();
	if (grec.next()) {
	   grec.work_notes = 'Action by = '+current.approver.getDisplayValue() ;
	   grec.update();
	}
})(current, previous);

 

-Anurag

View solution in original post

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Nagurbee1 ,

 

Please follow the steps below that I've completed for the change request table. You can replace the change request with the case table in the GlideRecord object.

 

Establish a business rule on the sysapproval_approver table that activates when the state changes to either approved or rejected.

In the script, we will use GlideRecord to ensure that the changes apply exclusively to the specified table and will update the work notes accordingly.

MoinKazi_0-1729863971852.png

 

MoinKazi_1-1729864010472.png

 

Output : 

MoinKazi_2-1729864080517.png

 

You can modify the business rule condition according to your needs; this is just an example of how to achieve your requirements.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You will need to write a BR that runs on Approval table (where Approval for is table in question only)

And then you can copy the state and comments etc to parent record.

-Anurag

Hello Anurag

Thank you so much for your quick response.

If possible , could you please post the sample script ?

 

Thanks in advance

Nagurbi

here is a sample, you can add more conditions and refine it as needed

 

AnuragTripathi_2-1729863955518.png

 

 

AnuragTripathi_0-1729863883654.png

 

 

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

	var grec = new GlideRecord("change_request");
	grec.addQuery("sys_id", current.sysapproval);
	grec.query();
	if (grec.next()) {
	   grec.work_notes = 'Action by = '+current.approver.getDisplayValue() ;
	   grec.update();
	}
})(current, previous);

 

-Anurag

Hello Anurag

Thank you so much, it has worked for me and I have accepted your solution.