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
Max_gMax_g 

Calling standard account page from VF page

I need to build a URL to call a standard account page from the selected account on a VF page.  I am getting to my class method, but my build of the URL is not correct. 

How do I build that pagereference?

 

Best Answer chosen by Admin (Salesforce Developers) 
MythiliMythili

In your pagerefernce give something like this

'https://ap1.salesforce.com/'+accid

 

accid= will hold the id of the Acount where you want ot be redirected.

Also ap1 should be replace to yur login region

All Answers

MythiliMythili

In your pagerefernce give something like this

'https://ap1.salesforce.com/'+accid

 

accid= will hold the id of the Acount where you want ot be redirected.

Also ap1 should be replace to yur login region

This was selected as the best answer
asish1989asish1989

Hi 

Try this code 

<apex:page controller="RedirectTOStandardPageController">
 <apex:form>
     <apex:pageBlock>
         <apex:selectList value="{!selectedAccountId}"  multiselect="false" size="1">
             <apex:selectOptions value="{!selectedList}"/>
             
         </apex:selectList>
         <apex:commandButton value="Go" action="{!redirect}"/>
     </apex:pageBlock>
 </apex:form> 
</apex:page>

 My Controller is 

public class RedirectTOStandardPageController{
    public List<Account> accountList;
    public List<SelectOption> selectedList;
    public Id selectedAccountId{get;set;}
    public RedirectTOStandardPageController(){
        accountList = new List<Account>();
        accountList = [SELECT id, Name FROM Account];
        
    }
    public List<Account> getAccountList(){
        return accountList;
    }
    
    public List<SelectOption> getSelectedList(){
        selectedList = new List<SelectOption>();
        for(Account act:accountList){
          selectedList.add(new SelectOption(act.id,act.Name)); 
        }
        return selectedList;
    }
    
    public PageReference redirect(){
        System.debug('@@@@@@@@@@@@@@@@ACCOUTID@@@@@@@@@@'+selectedAccountId);
        PageReference samePage= new PageReference('https://ap1.salesforce.com/'+selectedAccountId);
        samePage.setRedirect(true);
        return samePage;
    }
}        

 Did this post answers your question If so please mark it as solved.

Hit kudos If this post really helps you.

 

Thanks

Max_gMax_g

Thanks for the information.  Modified version worked just great.  used to format of '/' + accid.