Study for the Salesforce Platform Developer Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Practice this question and more.


What is the correct syntax to display the first name from the global variable user?

  1. {User.FirstName}

  2. {!User.FirstName}

  3. $User.FirstName

  4. {!$User.FirstName}

The correct answer is: {!$User.FirstName}

The correct syntax to display the first name from the global variable user is achieved through the use of the global variable syntax in Salesforce. By using "{!$User.FirstName}", you are correctly utilizing the necessary notation to reference global variables within formula fields, Visualforce pages, or Lightning components. This syntax starts with an exclamation mark, indicating that what follows is a merging of the dynamic global variable into the text or template. The dollar sign before "User" specifies that this is a global variable rather than a standard syntax variable. This format is essential for Salesforce to correctly interpret and fetch the FirstName field from the User object. The combination of the two symbols—exclamation mark and dollar sign—specifies that the reference is contextual and evaluated at runtime, allowing for accurate dynamic content rendering based on the user’s information in the current Salesforce session. This makes it the proper way to display dynamic user information like the first name. Other formats do not align with this required syntax or lack the required symbols for dynamic evaluation.