You need to sign in to do that
Don't have an account?
BWS
Trailhead: Visualforce Basics: Using Simple Variables and Formulas: Challenge
The Challenge for this (https://developer.salesforce.com/en/trailhead/force_com_programmatic_beginner/visualforce_fundamentals/visualforce_variables_expressions)Trailhead unit asks us to create a VisualForce page named "myHelloWorldVF" that displays the first name of the logged-in user.
Here is the VF I am using:
The error returned in Trailhead after clicking "Check Challenge" is:
I am not aware of a different global var within VF for getting User attributes.
Anyone have luck with getting this one to pass?
Here is the VF I am using:
<apex:page> {!$User.FirstName} </apex:page>(note: I have also tried wrapping the binding inside tags like <div>, <p>, <apex:outputText>, etc with no luck. I also tried minimizing the rendered output by including sidebar="false" standardStylesheets="false" showHeader="false")
The error returned in Trailhead after clicking "Check Challenge" is:
"Challenge not yet complete... here's what's wrong:
The Visualforce page did not fit the criteria. The first name of the loged in user was not output using dynamic global variables."
The Visualforce page did not fit the criteria. The first name of the loged in user was not output using dynamic global variables."
I am not aware of a different global var within VF for getting User attributes.
Anyone have luck with getting this one to pass?
Thank you for identifying this issue with the Visualforce challenge. We were able to replicate the issue and we found an error in our challenge implementation. We've pushed out a fix and so you can now attempt the challenge again and it should pass this time (you already have the right markup).
Apologies for the bug and thanks again for flagging the issue and helping us make Trailhead better! I would also love to get any suggestions/feedback that you might have on how we can improve the the overall Trailhead experience/content/chanllenges etc. (just use the 'Send Feedback' link in the app). Thanks
Sandeep
All Answers
To get Logged in user's first name:
{!$User.FirstName}
Here is the list of different global variables in Salesforce:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_global.htm
Thanks,
Pratik
P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
I tried it also - and got the invalid message also. Think it's possible that the Check has a bug in it?
Jeff
I am not exactly sure how the Trailhead app is checking and validating the VisualForce markup for this Challenge.
One GUESS is that it is using the Tooling API (via the Oauth access we grant it when starting the Challenge) to pull the specific ApexPage and inspect the Markup attribute for the appropriate use of "$User.FirstName". However, I am not exactly sure if it can do that as a "Connected App". I have never specifically built something like that (at least not yet).
I tested this out via the Rest Explorer in Workbench:
“/services/data/v32.0/query?q=SELECT+Markup+FROM+ApexPage+WHERE+Name+=+'myHelloWorldVF'”
Here are the results:
Thank you for identifying this issue with the Visualforce challenge. We were able to replicate the issue and we found an error in our challenge implementation. We've pushed out a fix and so you can now attempt the challenge again and it should pass this time (you already have the right markup).
Apologies for the bug and thanks again for flagging the issue and helping us make Trailhead better! I would also love to get any suggestions/feedback that you might have on how we can improve the the overall Trailhead experience/content/chanllenges etc. (just use the 'Send Feedback' link in the app). Thanks
Sandeep
Thanks a lot.
The challenge was cleared after removing the white spaces.
Also got a problem with this challenge as my fristname contains accented caracters ("é" in my case).
If fact, I hve replaced these caracters by "e" and the challenge was OK.
Hope this helps, specially those with this kind of caracters in their first name, and also guys behind the scene that make things possible with this very cool learning tool.
Regards,
Fred
--- Salesforce Answers
<apex:page>
{!$User.FirstName}
</apex:page>
"The first name of the currently logged-in user isn't output on your page using dynamic global variables."
With code
<apex:page >
<apex:pageBlock title="Display User Info">
<apex:pageBlockSection columns="1">
{! IF($User.IsActive,$User.FirstName & ' ' & $User.LastName, $User.FirstName & ' ' &$User.LastName & "is inactive")}
<p>This user is currently {! IF($User.IsActive, 'Active', 'Inactive')}</p>
<p>When logging in, they use the login of {! IF($User.IsActive, $User.Username, 'N/A')}</p>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Can anyone help resolving this issue?
Try this,
<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>