How to update the reply email

Royal1
Tera Contributor

 

In approval email: if we click on the reject option, the reply email update with the reject message.

 

now i want to add a note (NOTE: Please provide the rejection comments) in that reply email body & that comments should get update in the change notes section . Please suggest where i can update

 

Click here to reject SCTASK121211

2 REPLIES 2

Devender Kumar
Tera Guru
Tera Guru

Hi @Royal1 ,

Check the inbound action for reply email and in that add the code like below.

 

 

if(email.body.NOTE){

current.comments = email.body.Please_provide_the_rejection_comments;

current.update();

}

 

 

and in your reply email add the content like below

 NOTE:

Please_provide_the_rejection_comments:

 

Please refer the below links.

https://www.servicenow.com/community/developer-forum/email-response-to-update-a-record/m-p/1591332 

https://www.servicenow.com/community/developer-forum/update-additional-comments-field-with-user-mail... 

https://www.servicenow.com/community/developer-forum/inbound-email-action-want-just-email-body-comme... 

 

If my answer helps to resolve your issue then please mark it as correct and helpful.

Regards,

Devender

Riya Verma
Kilo Sage
Kilo Sage

Hi @Royal1 ,

Hope you are doing great.

 

To achieve the desired functionality where rejection comments provided in the approval email are updated in the reply email body and also reflected in the change notes section, we can implement the following solution:

  1. Edit the approval email template to include a specific section to capture the rejection comments from the approver. We can add a note like "NOTE: Please provide the rejection comments" to prompt the approver to enter their comments.

  2. Capture Comments in the Reply Email Body: Once the approver clicks on the "Reject" option in the approval email, the reply email is generated. We need to customize the email reply action to extract the comments provided by the approver. These comments will be used to update the change notes section.

  3.  Next, we need to implement a business rule or script that takes the comments captured from the reply email and updates the change notes section of the respective change request or record.

 

// Assuming the approval record's sys_id is stored in the variable 'approvalSysID'
var comments = current.comments; // 'current' represents the approval record

// Assuming the change request's sys_id is stored in the variable 'changeRequestSysID'
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(changeRequestSysID)) {
  changeRequest.comments += '\nRejection Comments: ' + comments;
  changeRequest.update();
}

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma