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

scott barnard1
Kilo Sage

Are you rejecting an approval or cancelling the change?

I am trying to achieve this when rejecting the approval which in turn would reject the change Ticket.

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.

Thanks for the script but is there any option to redirect the user to enter comments on Change Ticket after throwing an error message ? Also, i would only want this for the approvals associated with change request only and not with other task tables. any updated script which can help in this ?