Make comments mandatory on click of a ui action

luke_james2
Kilo Explorer

Good Afternoon everyone,

 

I currently have an issue where I need to make the comments field on the sys_approval table mandatory when a user is rejecting a change. This would work by the user clicking on the reject ui action and then it would not let them reject the change until a comment has been put into the comments field. Has anybody done this before?

 

Thanks,

 

Luke

10 REPLIES 10

Subhajit1
Giga Guru

Hi Luke,


Yes, you can do this by setting a Flag field on the Approval Form. The Flag field can be a True/False field.


Keep this field on the Approval form and Hide it unconditionally with a UI Policy.


Now, in your 'reject' UI Action, just add this line: current.u_flag ='true';



Now write another UI Policy, so that when the Flag is set to True, the Comments field turns Mandatory.



Thanks,


Subhajit


Thank you! This worked perfectly for me!

harikrish_v
Mega Guru

You can try an onsubmit client script like this:-



function onSubmit() {


  var action = g_form.getActionName();


  if(action=='reject'){


      g_form.setMandatory("comments",true);


}



}


Mike Allen
Mega Sage

I would incorporate the reject button into this:


http://www.servicenowguru.com/system-ui/glidedialogwindow-quickforms/



I think it is a better user experience, and can be used in the list view, as well.