Unknown property referenced error in Visualforce

172 views Asked by At

I am trying to use a global variable in Visualforce in the developer console while writing a Visualforce Page. I get the following error: Unknown property 'User.FirstName' referenced in UserStatus. UserStatus is the name of the Visualforce page. I am following along with a Salesforce Trailhead module so I do not understand why it would not work. Below is the code for the Visualforce Page.

<apex:page >
<apex:pageBlock title="User Status">

    <apex:pageBlockSection columns="1">
        {!User.FirstName & ' ' & $User.LastName }
        
        <p>
            Today's Date is {! Today() }
        </p>
        
        <p>
            Next week it will be {! Today() + 7 }
        </p>
    </apex:pageBlockSection>
    
</apex:pageBlock>

</apex:page>

1

There are 1 answers

1
Al Zenk On

I may have figured out the issue. The documentation shows the User global variable referenced with and without the $ character. For instance, {!User.FirstName} and {!$User.FirstName}. It appears that the $ character must be included.