RITM should be closed after setting state as Rejected and comments to be mandatory

Poorna Chandu
Tera Contributor

Hello Everyone,

 

I have a one approval activity in workflow, I have used setvalues activity and set the state as Rejected when approval is rejected. By doing this am able to get the state as Rejected in the RITM but its not getting closed and I need to make the additional comments as mandatory too before the RITM is closed so that user can fill in the reason for rejection before the RITM is closed.

Kindly help me in achieving this.

 

Regards

Poorna

5 REPLIES 5

Anurag Tripathi
Mega Patron
Mega Patron

HI,

This is usually done via a client script or UI policy on the approval record, When Approval is rejected the comments or rejection reason are mandatory. These same rejection reason can be copied in the workflow to your RITM and it can be closed.

-Anurag

Hello Tripathi,

 

Thanks for your response. May I request you to provide the code for the exact solution.

 

Regards

Poorna

Try this

 

Create after update BR on sysapproval_approver table

Condition: Comments Changes AND current.source_table == 'sc_req_item' and Status changes to reject

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sysapproval);

ritm.comments = current.comments.getJournalEntry(1);

ritm.update();

})(current, previous);

reate after update BR on sysapproval_approver table

Condition: Comments Changes AND current.source_table == 'sc_req_item'

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sysapproval);

ritm.comments = current.comments.getJournalEntry(1);

ritm.update();

})(current, previous);

 

-Anurag

Hello Tripathi, 

 

The above code will be applicable to all the catalog items but for only one specific catalog item it should be applicable.