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
GoodiesdGoodiesd 

Displaying a user's account name in a visualforce page

I am racking my brain trying to do something very simple in a visualforce page. I am displaying a SWF file and trying display and pass the current User's account name into the SWF. My problem is capturing the current user's account name for some reason. When I run it I get no errors and the SWF renders exactly as I expect, but when I am logged in as any user, I can not get it to display the account name. By all accounts, I assume I thought that the code below would bring back the current user's account name but I get nothing right now. 

{!User.Contact.Account.Name}

 

Any ideas would be much appreciated. I am definitely not an expert in this area but was hoping that I could put this very basic functionality together without a major effort. Thank you.

 

<apex:page standardController="User" sidebar="false" showheader="true">
     <apex:flash src="{!$Resource.mapsusage}?cscustomer={!User.Contact.Account.Name}"
     height="315" width="710" />
     {!User.Contact.Account.Name}
</apex:page>
Imran MohammedImran Mohammed

Did you try  {!$User.Contact.Account.Name}

GoodiesdGoodiesd

Greatly appreciate the suggestion. {!$User.Contact.Account.Name} resulted in the following error when I swapped it out:

 

Error: Field Contact.Account.Name does not exist. Check spelling.

NaishadhNaishadh

you can't access user account name in this way.

 

You have to do it in following way.

 

1. create custom controller and fetch account name in controller constructor. assign account name value to any variable.

2. access that variable in your URL

 

krishnagkrishnag

try using

 

{!$User.Contact.Account}