Checkbox field checked by default

Bouzaabia
Tera Contributor

Hello, 

please, how to do:

 one checkbox field be checked and mandatory , if  the state of request changed to closed

thank you

 

1 ACCEPTED SOLUTION

Hello,

If my answer helped you please mark it as correct.

Thanks.

View solution in original post

10 REPLIES 10

Hi Saini

thank you 

please i need it with onchange  client script, because i have others tasks(another field will be displayed  if the checkbox is checked) before close request .

You can use similar script for onchange and set checkbox default value as false.This will make the checkbox unchecked.

find_real_file.png

Saurav11
Kilo Patron
Kilo Patron

Hello,

So What I understood is You have a checkbox field when made true it will make another field appear so you want the field to be checked always when the state is changed to closed.

There are two approaches to this:-

1) Make field mandatory and true so no one can really save the form without checking it

Onchange client script will be as below:-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
var state = g_form.getValue('state');
if (state == '7')//State value of Closed
{ 

g_form.setMandatory('fieldname',true);
g_form.setValue('fieldname',true);

}
else
		
{ 

g_form.setMandatory('fieldname',false);

}

2) Make field true and read-only when state changes to close so that no cna can make it false(Better way)

Onchange client script will be as below:-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
var state = g_form.getValue('state');
if (state == '7')//State value of Closed
{ 
g_form.setReadOnly('fieldname',true);
g_form.setValue('fieldname',true);
}
else
{ 
g_form.setReadOnly('fieldname',false);
}
}

Please mark answer correct/helpful based on Impact

Hello,

Did you get a chance to see my code

Thanks.

Thank you Saurav