I'm new to this so please try to be extra patient with me :) Trying to display an message in the Account layout based on the Account name field. So what I've got working so far is the error message. Now, the problem is that if the message is not displayed (because rendered evaluated to false), it leaves a gaping blank section where the pageblock is. How can I make that section collapse if rendered equals to false? Found a post here that suggested using twistSection but didn't work.

Here's my code:

<apex:page standardController="Account"
<apex:pageBlock id="block1" rendered = "{!Account.Name = 'Test'}">
    <apex:pageBlockSection id="section1" columns="1" collapsible="true">
        <apex:pageMessage summary="Message" 
                  strength="3" />

<script> twistSection(document.getElementById('{!$Component.block1.section1}').getElementsByTagName('img')[0]) </script>


  • 1) Twistsection won't work because the pageBlockSection is never rendered initially so it doesn't exist for the javascript to find; 2) did you try putting the rendered= on a surrounding apex:outputPanel (surrounding to the pageBlock)?
    – cropredy
    Commented Jul 7, 2015 at 22:47
  • Just tried putting outputPanel before pageblock (and moved rendered there) but still the same thing. @crop1645
    – jekism
    Commented Jul 7, 2015 at 23:07
  • post an image of the rendered page annotated by what you want it to look like
    – cropredy
    Commented Jul 7, 2015 at 23:14

1 Answer 1


Change {Account.Name = 'Test'} to {!Account.Name == 'Test'}. You're also missing a " after your rendered=.

When accessing fields make sure your brackets start with {!.

  • 1
    For formulas and Visualforce expressions, = and == are identical. It's acceptable to simply write {!Account.Name='Test'}. You cannot assign a value using this syntax.
    – sfdcfox
    Commented Jul 7, 2015 at 21:16
  • The missing ! and quote at the end are typo errors, i have it as {! in the actual code. Sorry.
    – jekism
    Commented Jul 7, 2015 at 21:17
  • @sfdcfox Ah, thank you! I didn't know that.
    – user19038
    Commented Jul 7, 2015 at 21:18

You must log in to answer this question.

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