0

I am trying to display fields on the basis is value is null or not. I have used below code. Its not working. I am still wondering where is mistake.

I checked and confirms c.FlagEncrypted__c has values and not null.

 <apex:column headerValue="SSsk" rendered="{!IF(c.FlagEncrypted__c!=null,'YES','NO')} ">
  <apex:inputField value="{!c.FlagEncrypted__c}"/>
 </apex:column> 
0

1 Answer 1

1

Boolean values are always "true" or "false". Further, you never need an IF statement when doing a comparison. The following version should work equally well:

rendered="{!c.FlagEncrypted__c!=null}"

If you insist on using IF, then you must use TRUE or FALSE, and should not be in quotes:

rendered="{!IF(c.FlagEncrypted__c!=null,TRUE,FALSE)}"

Finally, it's considered idiomatic to use formula-style evaluation, so ideally you should write:

rendered="{!NOT(ISBLANK(c.FlagEncrypted__c))}"
4
  • Thanks SFDCFOX. Its not working for me, i found on page its displaying inputfield, but my coloum name is not comming. All rows are shifting one coloum head. Please advise. Should i put rendered condition in <apex:inputField value="{!c.FlagEncrypted__c}"/> also. Commented Apr 4, 2018 at 3:39
  • @DavidMycka No, rendered should affect the entire column. There's probably something else wrong in your code.
    – sfdcfox
    Commented Apr 4, 2018 at 3:43
  • @DavidMycka You can't use the field on a record for the header, because technically you haven't "entered the loop" yet. That's probably why it's behaving oddly.
    – sfdcfox
    Commented Apr 4, 2018 at 3:47
  • Thanks @sfdcbox. This column is part of pageblockTable where i am populating othere fields easily like c.firstname, c.lastname. Those are comming right. Please suggest. Commented Apr 4, 2018 at 3:55

You must log in to answer this question.

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