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
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>

 
chakravarthi paruchurichakravarthi paruchuri
Use this code before that just logout and login
<apex : page>
{! $User.FirstName}
</apex: page>
Rushika DebadwarRushika Debadwar
<apex:page>
    <apex:pageBlock title="User Status">
         <apex:pageBlockSection columns="1">
    {! $User.FirstName } {! $User.LastName } ({! $User.Username })
        </apex:pageBlockSection>
   </apex:pageBlock>
</apex:page>

Try to use this code you will pass the trailhead task.
Ghazala Syeda 13Ghazala Syeda 13
Visualpage name: DisplayUserInfo

<apex:page>
    <apex:pageBlock title="User Status Info">
        <apex:pageBlockSection columns="1">
            {! $User.FirstName}
            ({! IF($User.isActive, $User.FirstName, 'inactive') })
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
Varalakshmi Niharika JaguVaralakshmi Niharika Jagu
Hi, Use this code to get 100% in your challenge!
 
<apex:page >
    <apex:pageBlock title="User Status">
    	<apex:pageBlockSection columns="1">
        	{! $User.FirstName & ' ' & $User.LastName } ({! IF($User.isActive, $User.Username, 'inactive') })
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
Sunil KumawatSunil Kumawat
<apex:page label="DisplayUserInfo">
  {! $User.FirstName}
  {! $User.LastName }
  {! $User.Username }  
</apex:page>