The CreatorCon Call for Content is officially open! Get started here.

how to add comments made while rejecting the approval in RITM

Vijayenthiran S
Tera Contributor

When a request is rejected by the approver, he/she put a comment/reason as to why this request was rejected. i want to copy that comment and paste it to the RITM so that the requestor should know why their request was rejected.

8 REPLIES 8

Harshal Aditya
Mega Sage

Hi @Vijayenthiran S ,

 

You can easily fulfil your requirement by writing a after BR on sysapproval_approver table.

 

Regards,

Harshal

Chaitanya Redd1
Tera Guru

Hi,

 

You can try BR on sysapproval_approver table

(function executeRule(current, previous /*, displayValue, etc.*/) {
    // Check if the approval task was rejected
    if (current.state == 3 /*Rejected*/) {
        var rejectionComment = current.comments.getJournalEntry(-1); // Get the latest comment

        // Get the corresponding RITM
        var ritmGR = new GlideRecord('sc_req_item');
        if (ritmGR.get('sys_id', current.sysapproval)) {
            // Update the RITM with the rejection comment
            ritmGR.comments = "Rejection Comment: " + rejectionComment;
            ritmGR.update();
        }
    }
})(current, previous);

 

Hi Chaitanya Redd1,

 

Thanks for your response.

 

I tried your answer but it does not seem to working. Please assist. Thanks.

  Hi Chaitanya,

 

Thanks for your response. However, this doesn't seem to be working. Please let me know if something is wrong. Thanks a ton.

Screenshot 2023-08-24 012828.png

Screenshot 2023-08-24 012925.png