Enforce Mandatory fields on a client-side UI action

Rishi18
Kilo Expert

How can I enforce mandatory field check in a client-side UI action?

I've tried putting 'g_form.checkMandatory = true;' inside my function that is called on click and I want a check just like 'Save' UI Action, it should not allow further action if mandatory fields are not filled.

 

Thanks in advance!

Rishi

 

1 ACCEPTED SOLUTION

Inactive_Us1474
Giga Guru

There is one way to do this using below client side ui action :

if(g_form.mandatoryCheck() == true)
{
return false;
}
else return true;

 

Hope it helps.

 

View solution in original post

12 REPLIES 12

This will only work for fields that are mandatory by the dictionary and not by UI Policies or Data Policies

UI Action:

 

onclick: mandatory();

 

Script:

 

function mandatory()

{
var mandatory = g_form.getMissingFields();

if(mandatory == "")

{

return true;

}

else

{

return false;

}

}

I've already mentioned this to you in the previous response.

Thanks for your efforts though!

Daniele Songini
Tera Guru

Hi,

g_form.setMandatory('fieldname',true); // To make mandatory
g_form.setMandatoy('fieldname',false); //to make non-mandatory

g_form.setReadOnly('fieldname',true); // To make Readonly
g_form.setReadOnly('fieldname',false); //to make non-readonly

Please mark this as "Correct Answer" if I have given you a sufficient answer to your question.

Best Regards,
Daniele

Abhijeet Upadhy
Tera Expert

Hello Rishi

 

UI Action:

 

onclick: mandatory();

 

Script:

 

function mandatory()

{
var mandatory = g_form.getMissingFields();

if(mandatory == "")

{

return true;

}

else

{

return false;

}

}

 

Thanks

Abhijeet Upadhyay