+ Start a Discussion

Display Account informations in the customer portal



I would like create an apex code and a visualforce page to display the acount information of the current user in the customer portal.


This my code :


Apex class :

public with sharing class CustomerPortalController {

Id idCurrent = UserInfo.getUserId();
public user UserCurrent{get;set;}
public account AccountCurrentUser{get;set;}

  public CustomerPortalController(){
    UserCurrent = [SELECT AccountName__c FROM user WHERE Id=:idCurrent];
    AccountCurrentUser = [SELECT OwnerId, PreSales__c FROM account WHERE Name=:UserCurrent.AccountName__c];


Page :

<apex:page controller="CustomerPortalController" tabstyle="Account" showHeader="false">

Your Pre-Sales is {!AccountCurrentUser.PreSales__c}



Problem : the custom field "PreSales__c" is a lookup(user) and the page display the ID.

How can i display the name ?




Saikishore Reddy AengareddySaikishore Reddy Aengareddy

AccountCurrentUser = [SELECT OwnerId, PreSales__r.Name FROM account WHERE Name=:UserCurrent.AccountName__c];


In visualforce page use..


Your Pre-Sales is {!AccountCurrentUser.Presales__r.Name}


Hello Sam,


Thanks foy your answer.

I tried your solution, i have no error for save my code but when i display my page the value  {!AccountCurrentUser.Presales__r.Name} is blank.


however i have the good right on this field.

Do you have an idea ?


Thanks again,



Saikishore Reddy AengareddySaikishore Reddy Aengareddy

First to make sure this is working or not.. in your controller class remove "with sharing" and see if you are able to see the name. If visible then there should be some issue with security setting on custome rportal profile...


Make sure your object level and filed level settings are defined appropriately for customer portal profile. I am not really sure why this is not working..

else you could create a new formula field something like eg: (PresalesName__C = Presales__r.FirstName & " " & Presales__r.LastName) and refer that field in your visualforce page and make sure for this formula field appropriate field level security settings are applied for your portal profile.