making CHECKBOX variables READONLY and MANDATORY NOT working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 01:27 PM
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.
- Labels:
-
Service Catalog
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 01:33 PM
You have to setReadOnly false first. You can't make read only variables mandatory.
Please mark this as helpful/correct if it resolved your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 01:34 PM
In the code i have made it Readonly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 01:35 PM
You just need to pass the variable name as the first parameter. Remove the variable. part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 01:37 PM
checkbox variables are getting editable and mandatory as i needed, but when i make one of these checkboxes true leaving the rest unchecked, form gets submitted where it should not since they all are mandatory checkboxes