making CHECKBOX variables READONLY and MANDATORY NOT working

Pradeep67
Tera Contributor

HI, 

I hvae a onchange normal clientscript code which runs on sc_task when state changes. from the display BR i am taking the checkbox variables from the RITM and based on that i need to make the other set of checkboxes READONLY and MANDATORY. All the variables after submitting the request goes READONLY. 

MY code goes as below:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var st=g_form.getValue('state');
if(st=='3'||st=='4'||st=='7'){ // when state is complete/incomplete/skipped 
if(g_scratchpad.computer=="true"){
g_form.setMandatory('variables.received1',true);
g_form.setReadOnly('variables.received1',false);
}
if(g_scratchpad.headset=="true"){
g_form.setReadOnly('variables.received2',false);
g_form.setMandatory('variables.received2',true);
}
if(g_scratchpad.keyboard=="true"){
g_form.setReadOnly('variables.received3',false);
g_form.setMandatory('variables.received3',true);
}
}

This code is working fine, but when i test this, i observe that sc_task form gets saved if atleast one checkbox is true.

It is not maknig all the checkboxes mandatory, If one of the checkboxes is true form gets submitted.

Please assist me with this.

12 REPLIES 12

yes it is making mandatory, but when i try to check only one checkboxes out of three and submit it, it is getting submitted. where it should not because all the three checkboxes are mandatory

Do you have the three scratchpad variable set to true?

 

g_scratchpad.computer, g_scratchpad.headset and g_scratchpad.keyboard?

Add some alerts to check the same.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var st=g_form.getValue('state');

alert('g_scratchpad.computer - '+g_scratchpad.computer +'- g_scratchpad.headset-'+g_scratchpad.headset+'-g_scratchpad.keyboard-'+ g_scratchpad.keyboard);
if(st=='3'||st=='4'||st=='7'){ // when state is complete/incomplete/skipped 
if(g_scratchpad.computer=="true"){

g_form.setReadOnly('variables.received1',false);
g_form.setMandatory('variables.received1',true);

}
if(g_scratchpad.headset=="true"){
g_form.setReadOnly('variables.received2',false);
g_form.setMandatory('variables.received2',true);
}
if(g_scratchpad.keyboard=="true"){
g_form.setReadOnly('variables.received3',false);
g_form.setMandatory('variables.received3',true);
}
}


Please mark this response as correct or helpful if it assisted you with your question.

Akshay H Mulky
Kilo Guru

Hi Pradeep,

Can you try these:

var st=newValue;

if(((st=='3')||(st==3))||((st=='4')(st==4))||((st=='7')||(st==7)))

((g_scratchpad.computer=="true") || (g_scratchpad.computer==true))