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
Antoine_LeleuAntoine_Leleu 

Display Account informations in the customer portal

Hello,

 

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 {

//variables
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}

</apex:page>

 

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

How can i display the name ?

 

Thanks,

Antoine

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}

Antoine_LeleuAntoine_Leleu

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,

 

Antoine

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.