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

bernyalvarado
Mega Sage

Hi aarav, do you have any further questions around this post?



Do you believe you can mark the responses as helpful and/or correct so that we can close this thread?



Thanks,


Berny


Milind Gharte
Kilo Guru

Hi,

Here is link for your solution.

https://community.servicenow.com/community?id=community_question&sys_id=4c02dbeddbdcdbc01dcaf3231f96...

 

If it Helps,please mark it as Correct and Helpful.


Warm Regards,


Milind