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
salesforce_newbiesalesforce_newbie 

Should this code work?

Hi All,

 

I'm wondering if this code should work or am I doing something wrong.  So I only want to display a section header if there is text in the section.

 

 

 

<apex:outputPanel id="output1" rendered="{ISNULL(!Position.Values__c)}"> 

<apex:outputLabel value="Values Statement"></apex:outputLabel></h4></apex:outputPanel> <br/><br/> <apex:outputText value="{!Position.Values__c}" id="thevaluessection"/><br/>

 

 

I have an object, Position, and it has several different field.  This object is used to display info on a webpage so when the salesforce user doesn't fill in the 'Values' field, I don't want that section to appear on the webpage.

 

Thanks in advance.

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

Your outputpanel has rendered="{isnull{!Position.Values__c)}". This is not formatted right; I think you meant rendered="{isnull{!Position.Values__c)}". But this won't work either, because if Position.Values__c is null, then ISNULL(Position.Values__c) evaluates to TRUE. Therefore rendered will only equal TRUE if there is nothing in Position.Values__c. 

 

I think you want the opposite of that. Try rendered = "{!!ISNULL(Position.Values)}". The first ! is equivalent to NOT(). Therefore your outputpanel will only be rendered if Position.Values__c is NOT NULL.

 

Let me know if this doesn't solve the problem.

Jeremy

All Answers

Jeremy.NottinghJeremy.Nottingh

Your outputpanel has rendered="{isnull{!Position.Values__c)}". This is not formatted right; I think you meant rendered="{isnull{!Position.Values__c)}". But this won't work either, because if Position.Values__c is null, then ISNULL(Position.Values__c) evaluates to TRUE. Therefore rendered will only equal TRUE if there is nothing in Position.Values__c. 

 

I think you want the opposite of that. Try rendered = "{!!ISNULL(Position.Values)}". The first ! is equivalent to NOT(). Therefore your outputpanel will only be rendered if Position.Values__c is NOT NULL.

 

Let me know if this doesn't solve the problem.

Jeremy

This was selected as the best answer
salesforce_newbiesalesforce_newbie

Thanks Jeremy that works great!

 

When I used it in the sandbox it worked perfectly but when I tried it in the live version, it's not working.

Do you know why this might be happening?

 

Thanks

salesforce_newbiesalesforce_newbie

Sorry ignore that..it was my silly mistake.

 

Thanks again for your help :smileyvery-happy:

Jeremy.NottinghJeremy.Nottingh

Maybe if you post some more details. What controller is this page using? If it's custom, please post that code as well as more of the page itself.

 

Thanks,

Jeremy

saharisahari

<apex:outputtext rendered="{ISNULL(!pos)}">

 

Is this the correct way to render th output text?

here pos is a List.

So I am trying to to display this text incase if this List evaluates to null.

 

Please help