Add comment to RITM upon approval expiration

nkouloungis
Tera Contributor

In the request management workflow, I can add an approval and set a due date for that approval with instruction to reject the RITM if the due date is reached with no action. This results, by OOTB design, in the approval being "no longer required" and the RITM.approval being "rejected".

 

However, if I'm the requester or anyone else reviewing the record, it may not be clear that the RITM was rejected due to approval expiration. I wanted to add an automatic comment to the RITM that explicitly states that the record update resulted from approval expiration. Has anyone else done this? If so, what was your approach? How do you build a condition that isolates the expiration event in the workflow?

1 ACCEPTED SOLUTION

Aditya_hublikar
Kilo Sage

Hello @nkouloungis ,

 

Yes, this is a common gap in the ServiceNow OOTB approval behavior. By default, when an approval reaches its due date with no action, ServiceNow marks the approval as “No longer required” and sets the RITM approval to “Rejected”, but it does not clearly explain why the rejection happened. This can definitely confuse requesters or reviewers.

To solve this, the best approach is to add an automatic comment or work note on the RITM at the time the approval expires, explicitly stating that the rejection happened due to approval expiration.

 

You can create BR which will add this cooment automatically .

 

table:sysapproval_approver

when:after update 

condition: state chnages to No Longer required

                     due date is not empty 

 

Add this script :

(function executeRule(current, previous) {

// Ensure approval expired (not manually rejected)
if (current.state == 'not_required' &&
current.due_date &&
new GlideDateTime() >= new GlideDateTime(current.due_date)) {


var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.sysapproval)) {

ritm.comments =
'Request was automatically rejected because the approval was not actioned before the due date.';
ritm.update();
}
}

})(current, previous);

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

 

 

 

 

View solution in original post

4 REPLIES 4

Aditya_hublikar
Kilo Sage

Hello @nkouloungis ,

 

Yes, this is a common gap in the ServiceNow OOTB approval behavior. By default, when an approval reaches its due date with no action, ServiceNow marks the approval as “No longer required” and sets the RITM approval to “Rejected”, but it does not clearly explain why the rejection happened. This can definitely confuse requesters or reviewers.

To solve this, the best approach is to add an automatic comment or work note on the RITM at the time the approval expires, explicitly stating that the rejection happened due to approval expiration.

 

You can create BR which will add this cooment automatically .

 

table:sysapproval_approver

when:after update 

condition: state chnages to No Longer required

                     due date is not empty 

 

Add this script :

(function executeRule(current, previous) {

// Ensure approval expired (not manually rejected)
if (current.state == 'not_required' &&
current.due_date &&
new GlideDateTime() >= new GlideDateTime(current.due_date)) {


var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.sysapproval)) {

ritm.comments =
'Request was automatically rejected because the approval was not actioned before the due date.';
ritm.update();
}
}

})(current, previous);

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

 

 

 

 

Hello @nkouloungis ,

 

I hope you are doing well. Does this response helps you ?  

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

Yes. Thank you. This appears to accomplish the desired functionality.

Ankur Bawiskar
Tera Patron

@nkouloungis 

script from @Aditya_hublikar should help

please try that and share the feedback

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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