Add Approval and rejection information to the related ticket worknotes

Jacob64
Kilo Guru

Hi all,

We want to add Approval and above all rejection reason information to the worknotes of the related records.
2 examples:
* When we request for an approval for a request or catalog item approving the request is easy and no questions are normally asked. However sometimes the approver has a comment that is important of even more when the request is rejected we want to know why it is rejected. For this we already use a field that shows the reason but a normal enduser cannot see that and contact the servicedesk for that. And the servcicedesk needs to look into the approval taks to check this. This is inconvenient and unwanted.

* Similar for change requests where we ask members of our tCAB and CAB to approve. Again the approver sometimes has a comment that is important of even more when the request is rejected we want to know why it is rejected. Also for this we already use a field that shows the reason and additional we also use a rejectioncode field (change specific) but again a normal enduser cannot see that and will contact the servicedesk for that. And the servcicedesk needs to look into the approval taks to check this. This is inconvenient and unwanted.

So in short wat we want is always add any approval comment and esspecially rejection reason and rejection codes for changes to be added to the related record. For a request that means that te rejection reason is added to the comments of the request and for a change the rejection reason plus rejection code is always added to the related change record.

We already tried all kind of ways to add this but for some reason it does not work.

Can someone help me here?

Many thanks in advance!

KR
Jacob.

2 REPLIES 2

JenniferRah
Mega Sage

We created a business rule that runs on the sysapproval_approver table whenever the state changes to Approved or Rejected and the Approval for record is a RITM. It adds a comment to the parent item. Ours is specific to RITMs, but you could modify it to work with other record types, too.

 

(function executeRule(current, previous /*null when async*/ ) {
    var parentReq = new GlideRecord("sc_req_item");
    parentReq.get(current.sysapproval);
        if (current.state == "rejected") {
                if (current.comments != "") {
                    parentReq.comments = current.approver.getDisplayValue() + " rejected sign-off with following comments:  " + current.comments + ".";
                }else{
                    parentReq.comments = current.approver.getDisplayValue() + " rejected sign-off.";
                }
        } else {
            if (current.state == "approved") {
                if (current.comments != "") {
                    parentReq.comments = current.approver.getDisplayValue() + " provided sign-off with following comments: " + current.comments + ".";
                } else {
                    parentReq.comments = current.approver.getDisplayValue() + " provided sign-off.";
                }
            }
        }
        parentReq.update();
})(current, previous);

  

Ankur Bawiskar
Tera Patron
Tera Patron

@Jacob64 

you can use the OOTB inbound email action on sysapproval_approver table and update the logic there.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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