function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arun KArun K 

checkbox disable according to user field

I have a Vf page where I have pageblocktable of Account with checkbox.

In account I have  'doctype' field whose values could be 'hyp' or 'wel' or 'hyp and wel'


I have a 'reptype' field in User object suppose 'hyp'


In pageblocktable I need checkbox to be disabled according to rep type.


For ex,


1----If user reptype is 'hyp only', then disable accounts with value 'hype + wel' and 'hyp heavy'

2----If user reptype is 'wel', then disable accounts with value 'wel heavy' and 'well + hype'




You can do something like this



Example 1.

<apex:inputCheckbox value="{!acc.isChecked__c}" disabled="{!($user.reptype=='hyp' && acc.doctype=='wel')}"/>

 You can add other condition by doing an OR in the disabled attribute 


disabled="{!($user.reptype=='hyp' && acc.doctype=='wel') || (Condtion 2 here) }"
Arun KArun K

Thanks for the reply.


If I do that way, What about user of other reptype like'wel'.


I want to disable the checkboxes dynamically.

You will have to put the logic somewhere, You can always append the condition by doing OR.

Or you can use a wrapper class to disable the checkboxxes
Arun KArun K

In other words, I want to disable records which match field value.

I guess you should able to use above code to deduct whatever you want.
This code gives you a Idea about how to disable checkbox based on condiftions
Arun KArun K

Can you elaborate the way to do it in both ways.?

Hi Arun,

Have you found out how to do this. I have similar requirement lik this with lead record.
Arun KArun K

I created field in object with the valuee that I use and used disabled attribute to disable checkbox.



I have similar scenario as yours. But the issue is i have a multi-select picklist field when i append it in disabled i get error as  multiselect picklist cannnot be used in this tag.

Could you pleae suggest a way hoe to achieve.

<apex:inputCheckbox value="{!leadVar.isSelected}" onclick="childCheck(this.checked)" disabled="{!IF($User.GCAM_Region__c == leadVar.RI_Zone__c,false,True)}"/>

GCAM_Region__c is a multiselect picklist in User Object.