Stop UI action to work if field is empty

Kumar147
Tera Contributor

I have created a UI action to create another ticket. I need to make some fields mandatory to create that ticket. So if mandatory field is empty and when clicked on UI action that should not work. I need to make that in UI action script. Can anyone help me out this thing.

7 REPLIES 7

Mohith Devatte
Tera Sage
Tera Sage

Hello ,

You can write an On click function and call your mandatory ode inside it like below

function checkMandatory() // call this function in onclick field

{

if(g_form.getValue('your field name')=="") //check if field is empty

{

alert("few fields are mandatory please fill");

return false;

}

}

Please mark my answer correct if it helped you

Hi Mohit,

I have tried this one it is showing alert but on click function is not working, no response is coming when I clicked on the UI action

Can you please share the code and screenshot of the entire UI action configuration ?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

in the UI action script itself you can check if the mandatory fields are filled or not

If yes then proceed for ticket creation

If not then stop the form

something like this if your UI action is server side

if(current.u_field1 == '' || current.u_field2 == ''){
	gs.addErrorMessage("Please fill mandatory fields");
}
else{
	// your logic here
}

You can do something similar in client side UI action as well

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader