+ Start a Discussion
Pawan Kumar 32Pawan Kumar 32 

Create a Visualforce page that shows user information

Hello All,
I am stuck in below trailhead chanllange
Create a Visualforce page that displays the first name of the logged-in user.
  • The page must be named 'DisplayUserInfo'.
  • The displayed user information must be generated dynamically from the logged-in user.
Here below is my code. Please help me to find the solution.
<apex:page>
{!$User.FirstName } {!$User.LastName } ({!$User.Username })
</apex:page>
Best Answer chosen by Pawan Kumar 32
sfdcdevsfdcdev
Log out from the account which you're using to check the challenge and log in again to recheck the challenge.

All Answers

sfdcdevsfdcdev
Remove ({!$User.Username }) from your code.
 
<apex:page >
 {!$User.FirstName}
</apex:page>

 
Pawan Kumar 32Pawan Kumar 32
@sfdcdev still not working.. please refer below screen shot
User-added image
User-added image
sfdcdevsfdcdev
Log out from the account which you're using to check the challenge and log in again to recheck the challenge.
This was selected as the best answer
Pawan Kumar 32Pawan Kumar 32
Thank you all for the help.. Now my code is working fine :)
Rakesh Behera 8Rakesh Behera 8
@Pawan Kumar :  How did you make it work.
I am also getting the same error while trying it in developer edition?
aman batra 3aman batra 3
please use below code:

<apex:page>
  <apex:pageblock>
  <apex:pageblockSection>
  {!$user.firstname}
  </apex:pageblockSection>
  </apex:pageblock>
</apex:page>
Ajit JhaAjit Jha
Hi Pawan,
As i could check your code, you have used global variable $User to print Username as well... So just remove ({!$User.Username }) and Print only first name or you can print both (firstname and lastname).

Working code is:

<apex:page >
    {! $User.FirstName }
</apex:page>