0 votes
1 view
in Salesforce by (11.3k 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 (28.6k points)

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

...