How to make filed visible and mandatory when Form button is clicked

aarav
Kilo Contributor

Hi Team.

I want to make filed(rejected reason) Visible and make it mandatory when the 'Rejected' form button is clicked.

----------------------

Existing code   for Rejected form button is clicked

When Rejected form button is clicked ..Comments button becomes mandatory.

and the code for this is

--

current.state = 'rejected';

if(!JSUtil.nil(current.comments))

      current.update();

else{

      gs.addErrorMessage("Comments are required when rejecting an approval");

      current.state = 'requested';

      current.setAbortAction(true);

}

----------------

can i add the code to above code to make my field visible and mandatory   or do i need to write new UI action or something else..

Please suggest

Aarav.

16 REPLIES 16

achacko
Kilo Guru

Hi Aarav



You can create a UI policies, please refer to the ServiceNow document   UI policies



Regards



Anil


aarav
Kilo Contributor

Thank you Anil.


But i need steps on Form button....not on the field.



Aarav


bernyalvarado
Mega Sage

I hope this helps


sachin_namjoshi
Kilo Patron
Kilo Patron

This SNGuru post should be just what you need.



http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action



Regards,


Sachin


manishaidhate
Mega Expert

You can try it by Business Rule (adding table on which you want )   as below, and use script for making field visible and mandatory


find_real_file.png