I want to decide to show/hide a particular text when an Account detail page is loaded, based on the user logged in.

How can I achieve this i.e. making a decision when the account detail page is loaded. Till now I have created a visual force page to show the custom text when a button is clicked. But I want to make the decision when the account detail page loads as per the user logged in.

Thanks a lot.

  • You want to check the user in your controller? Or the profile of the logged in user?
    – highfive
    Aug 18, 2014 at 7:53
  • are you using visualforce page jus for this requirement ? You can do this in a standard detail page itself right ? Aug 18, 2014 at 8:02

1 Answer 1


This rather depends where the custom text is going to live.

If you can use a formula field to generate the text, you can conditionally display it based on the user's profile using the $Profile global.

If not, or if you need HTML type markup or similar, you can embed a Visualforce page into the standard record view page and generate the output based on the profile or other information about the logged in user. You can get at some user information in the Apex controller via the UserInfo class - this contains the id of the current user, so you can retrieve the user record using a SOQL query, e.g.

    User currUser=[select id, ManagerId from User where id=:UserInfo.getUserId()];
  • I will try this and see if this matches my requirement.
    – ParoTech
    Aug 18, 2014 at 8:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .