Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I have a visualforce component which I use for displaying the user's name. Currently, I am doing it using the following:

!$User.FirstName} {!$User.LastName}

Is there any way I can display the User's Account as well as using this without writing SOQL. I would not like to create a controller just to display the user's account and am hoping there is a simpler and easier way using just Visual force.

I did try !$User.Contact.Account}

But it gave me an error.

Thanks.

1 Answer

0 votes
by (32.1k points)
edited by

The following two things you may want to try:

  1. Reference the Account Name from the $User Visualforce global variable.

    {!$User.Contact.Account.Name}

  2. If that doesn't work, create a new formula field on the User object named Contact Account Namewith this formula: Contact.Account.Name. Once you have created that formula field, you should be able to reference it in Visualforce using: {!$User.Contact_Account_Name__c}.

Want to become a Salesforce Expert? join Salesforce certification now!!
 

Browse Categories

...