0

I have one Input field and one Output field.

And I have two Boolean fields Boolean 1 and Boolean 2 from Controller.

Condition 1: If Boolean 1 is true and Boolean 2 is false the value should come in output field.

Condition 2: If Boolean 1 is true and Boolean 2 is true the value should come in input field.

I need to know the condition to be checked in rendered

I wrote like as follows its not working.

<apex:outputfield value="{!fieldname}" rendered="{!IF(AND(Boolean 1 == true, Boolean2 == false), TRUE, FALSE)}"/>

<apex:inputfield value="{!fieldname}" rendered="{!IF(AND(Boolean 1 == true, Boolean2 == true), TRUE, FALSE)}"/>

1 Answer 1

5

Yes, it should work as written, although for efficiency, you should write it as follows:

rendered="{!AND(Boolean1, NOT(Boolean2))}"

rendered="{!AND(Boolean1, Boolean2))}"

There's no need for the IF statement; whenever you have FALSE and TRUE in your source code, you're probably doing something wrong.

You might also make it easier on yourself to simply put in an outer rendering element, but this may not work in all scenarios:

<apex:outputText rendered="{!Boolean1}">
  <apex:outputField rendered="{!NOT(Boolean2)}" ... />
  <apex:inputField rendered="{!Boolean2}" ... />
</apex:outputText>

Note that apex:inputField and apex:outputField observe field security. If your field is not rendering as expected, check your field level security.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .