How to make checkboxes readonly and checked as true on catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 10:51 PM
Hi All,
I have catalog item with two 'multiple choice' variables named 'Group Type & Level of permission'.
Group type check boxes are grayed out based on variable.
Here my requirement is when 'S-Security Incident Response' is checked and sub type of the group is one of 'level1_sir_admin or level2_security_assignment or level3_readonly' then we need to make the level1,level2 and level3 checkboxes readonly false else need to make readonly true.
to achieve the same i have written one onChange client script.
================================================
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var reqType = g_form.getValue('request_type');
var groupSubType = g_form.getValue('existing_group');
if(reqType == 'Modify Group' && newValue == 'true'){
alert('@123 inside');
var ga = new GlideAjax('gettingsubtypeofgroup');
ga.addParam('sysparm_name','groupSubType');
ga.addParam('sysparm_group_sys_id',groupSubType);
ga.getXML(GetSubTypeofGroup);
}
}
function GetSubTypeofGroup(response){
var subtype = response.responseXML.documentElement.getAttribute("answer");
alert(subtype);
if(subtype == 'level1_sir_admin'){
alert('@123 inside level of authorization:'+subtype);
g_form.setReadOnly('level_of_permission', 'false');
}else{
alert('@123 inside else level of authorization');
g_form.setReadOnly('level_of_permission', 'true');
}
/*g_form.setValue('level1_sir_admin', 'true');
g_form.setValue('level2_security_assignment', 'false');
g_form.setValue('level3_readonly', 'false');
}else if(subtype == 'level2_security_assignment'){
alert('@123 inside level of authorization:'+subtype);
g_form.setReadOnly('level_of_permission', 'false');
g_form.setValue('level2_security_assignment', 'true');
g_form.setValue('level1_sir_admin', 'false');
g_form.setValue('level3_readonly', 'false');
}else if(subtype == 'level3_readonly'){
alert('@123 inside level of authorization:'+subtype);
g_form.setReadOnly('level_of_permission', 'false');
g_form.setValue('level3_readonly', 'true');
g_form.setValue('level1_sir_admin', 'false');
g_form.setValue('level2_security_assignment', 'false');
}*/
}
=======================
But changes are not reflcating properly, can you please help me.
Regards,
Kotaiah Sadari

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 10:56 PM
The second argument for g_form.setReadOnly() should be a boolean. You have strings.
This:
g_form.setReadOnly('level_of_permission', false);
NOT this:
g_form.setReadOnly('level_of_permission', 'false');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 11:05 PM
Hi Geoffrey,
I changes as boolean now also not working.
Regards,
Kotaiah Sadari

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 11:49 PM
I couldn't tell you what else is wrong without more information.
Are you seeing all of the alert popups?
Are you getting a response from the GlideAjax?
Are there any errors in the console log?
I don't understand why your "Multiple choice" variable is rendering as checkboxes when I see radio buttons. There must be more to it than what you have described.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 11:56 PM
I am not sure that OnChange script will work on your Checkbox to make it checked or Read-only.
You can make it checked onChange but it also remain in background.