making ui reference fields readonly or disabled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 01:19 PM
Hi Experts,
I'm building an UI Page with a couple ui reference fields that I want to make readOnly or disabled unless another field has been checked. I'm trying to do this with javascript:
if (document.getElementById("my_plan").checked){
document.getElementById('b_plan_name').readOnly = false;
document.getElementById('b_plan_name').style.backgroundColor = '#fff' ;
} else {
document.getElementById('b_plan_name').readOnly = true;
document.getElementById('b_plan_name').style.backgroundColor = '#ddd' ;
}
This code seems to work with other input fields but does not work with ui reference fields. Is there a way to do this?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 02:00 PM
If you need to use processing script, then you can use below
var mplan= request.getParameter("my_plan");
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 02:10 PM
Hi David,
I have tried below example, which may be helpful for you :
HTML:
<g:ui_reference name="assigned_to" table="sys_user" />
Client Script:
function setReadOnlyReference(field_name, flag) {
if(flag == false)
jQuery('#sys_display\\.'+field_name+', #lookup\\.'+field_name+'').removeAttr('disabled');
else
jQuery('#sys_display\\.'+field_name+', #lookup\\.'+field_name+'').attr('disabled','disabled');
}
For readOnly reference field:
setReadOnlyReference('assigned_to');
For editable :
setReadOnlyReference('assigned_to' , false);