Make"Rejection" comments mandatory while rejecting a Change via List Context menu UI Action i.e. Right Click Reject option in Change Approvers related list.

sarthak92
Giga Expert

There is a requirement to make the "comments" mandatory if someone rejects the Change Ticket via the list context menu UI Action i.e. right click on the Approver related list. I managed to make some modifications in the script posted in the community by someone else with similar requirement but its not working as expected. Although, after clicking Reject, its redirecting to enter the mandatory comments but after entering the comments, state is not changing to "Rejected". Can anyone help on this ?

function rejectRequest()

{
if (g_form.getValue('comments') == '')

{
//Remove any existing field message, set comments mandatory, and show a new field message

try {g_form.hideFieldMsg('comments');} catch(e) {}

g_form.showFieldMsg('comments','Please provide comments for rejection.','error');

return false; //Abort submission

}

//Call the UI Action and skip the 'onclick' function

gsftSubmit(null, g_form.getFormElement(),'Reject'); //MUST call the 'Action name' set in this UI Action

}

if (typeof window == 'undefined')

serverReject();

function serverReject()

{

current.state='rejected';

current.update();

}

Note : function rejectRequest(); is in 'Onclick' field of the ui action form.

1 ACCEPTED SOLUTION

scott barnard1
Kilo Sage

I use this as a ui action on the approval table with appropriate conditions

 

current.state = 'rejected';

if (!gs.nil(current.comments))
current.update();
else {
gs.addErrorMessage(gs.getMessage("Comments are required when rejecting an approval"));
current.state = 'requested';
current.setAbortAction(true);
action.setRedirectURL(current);
}

 

Bear in mind what you want your state to be if they don't add the comment.

View solution in original post

19 REPLIES 19

Harish KM
Kilo Patron
Kilo Patron

can you share the UI action screenshot?

Regards
Harish

Attached now 🙂 

Can you add "Reject" in Action name and try?

 

Regards
Harish

Hi Harish, This did not solve the issue. Already tried putting this earlier, 🙂 Trying my luck with Scott's script now 🙂