Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add rejection comments in the notification sent when a request is rejected

Atheher Fathima
Mega Guru

Hi All,

 

We have existing notifications set up on sysevent_email_action table to trigger an email when a request is rejected. The requirement now is to include the rejection comments to be captured in this email notification. Please note the comment is mandatory while rejecting a request.  I am unable to find the correct option to be selected here. I am trying this on sc_request and sc_req_item tables.

 

any guidance on how to achieve is greatly appreciated.

 

Thank you

Atheher Fathima

2 REPLIES 2

Kamil Smusz
Kilo Sage

Hi @Atheher Fathima ,

 

Comments will be in sysapproval_approver table

SN_Learn
Kilo Patron
Kilo Patron

Hi @Atheher Fathima ,

 

You can setup a new email script in the table [sys_script_email] and call it in the already setup notification.

 

The email script can be called in notification as below

${mail_script:<name_of_email_script>}

 

Code for the email script:

var getRejectionNotes = new GlideRecord('sysapproval_approver');
getRejectionNotes.addQuery('sysapproval', current.sys_id);
getRejectionNotes.query();
if(getRejectionNotes.next())
{
 template.print("Rejection Note(s): " + getRejectionNotes.comments.getJournalEntry(1));
}

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.