is it possible to make a true/false field mandatory?

garethprice
Kilo Expert

I've been trying to make a true/false field mandatory on the Service Desk Call Plugin. I've tried a couple of variations of UI policies and the field shows with a grey star as if it was mandatory once but i'm unable to make the field mandatory if false and not mandatory if true

any suggestions?

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Although you can "make" a True/False field (checkbox) mandatory, it always contains a true or false value so it will always be considered to be filled in regardless of the status.   That's why you see the grey star - it's mandatory AND "filled in".



I always create a choice field with "Yes" and "No" options and include a blank option that fails the mandatory check.


View solution in original post

7 REPLIES 7

amlanpal
Kilo Sage

Hi Gareth,



First of all, let me clear your idea a bit regarding your issue. The field/variable is successfully set to Mandatory and that's why the mandate star is there. Again the star is Grayed because already a value is set in the field/variable. Now the question should come, why it is grayed even though it is not checked? As the field type is 'True/False', the field's value can be either 'True' or 'False'. And as the field is not checked that mean's it's value is set as 'False' by default and that's why the Grayed Star is there.


Now let me come to your requirement. You need to ensure that before the form is submitted the field should be checked or in other word the field value should be 'True'. For this you need to write a onSubmit Client Script (or Catalog Client Script if it is variable) as of below:


var value = g_form.getValue('field_name');


if(!value {//this evaluates as if the checkbox is not checked


alert('Provide Your Alert Message To Check The Field');


return false; //Restrict the form from submitting


}



I hope this helps.Please mark correct/helpful based on impact



hey amlanpal, I tried this, but I'm still able to submit my form without the checkbox being checked.  any suggestions?

garethprice
Kilo Expert

Update to this -



I have created a multiple choice variable, the multiple choice has just one choice and is defaulted to empty.


Making this variable mandatory has solved this issue