+ Start a Discussion
venkatsforcevenkatsforce 

show a standardview page using custom button

i want to show the standardview from visualforcepage using custom button.....any examples....

Best Answer chosen by Admin (Salesforce Developers) 
venkatsforcevenkatsforce
I use like this in commandbutton and got the o/p....
<apex:commandButton id="aid" action="{!URLFOR($Action.Account.view, acc.id)}" value="Details"></apex:commandButton>

All Answers

Shiv ShankarShiv Shankar

http://yourinstenceName/recordId

 

like

 

https://cs10.salesforce.com/a02J0000001b27i

venkatsforcevenkatsforce

Ths s my code

 

<apex:page controller="showAccountdetails">
 <apex:form >
   <apex:pageBlock >
    <apex:pageblockTable value="{!account}" var="acc">
      <apex:column value="{!acc.Name}"/>
      <apex:column value="{!acc.Phone}"/>
      <apex:column value="{!acc.Industry}"/>
      <apex:column headerValue="Action">
      <apex:commandButton value="Details" action="{!showDetails}">
      <apex:param name="accId" value="" assignTo="{!accId}"/>
     </apex:commandButton>
      </apex:column>
    </apex:pageblockTable>
   </apex:pageBlock>
 </apex:form>
</apex:page>

 

 

 

public class showAccountdetails
{
    public PageReference showDetails()
    {
         String recordId= apexpages.currentpage().getParameters().get('accId');
        // for(Account ac:[Select Id,Name from Account where Id=:id])
         PageReference pg = new PageReference('https://ap1.salesforce.com/001/Account/RecordId');
       // PageReference pg= new PageReference('ap1.salesforce.com/=+{Id}'&retURL=%2F'+recordId );
         return pg;  
    }
 
    public String accId { get; set; }
    public List<Account> account { get; set; }
    public showAccountdetails()
    {
       LoadAcc();  
    }
    
    public void LoadAcc()
    {
      account = [Select Name,Phone,Industry from Account];
    }
}

 

 

if it is execute means it shows one details button in each column and if i click means its move on to standardpage......

Any Changes in this code ,Help.......

Chamil MadusankaChamil Madusanka

 

Try these changes.

public class showAccountdetails
{
    public PageReference showDetails()
    {
         String recordId= apexpages.currentpage().getParameters().get('accId');
        // for(Account ac:[Select Id,Name from Account where Id=:id])
         PageReference pg = new PageReference('/'+RecordId);
		 pg.setRedirect(true);
       // PageReference pg= new PageReference('ap1.salesforce.com/=+{Id}'&retURL=%2F'+recordId );
         return pg;  
    }
 
    public String accId { get; set; }
    public List<Account> account { get; set; }
    public showAccountdetails()
    {
       LoadAcc();  
    }
    
    public void LoadAcc()
    {
      account = [Select Name,Phone,Industry from Account];
    }
}

 Hit the Kudos button if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.

 

venkatsforcevenkatsforce

In AddressBar its shows like this at the time of click the detail button

 

https://ap1.salesforce.com/null

 

 

Shiv ShankarShiv Shankar

Do this change with showDetails method

public PageReference showDetails()
    {
         String recordId= apexpages.currentpage().getParameters().get('accId');
        // for(Account ac:[Select Id,Name from Account where Id=:id])
    PageReference pg = new PageReference('https://ap1.salesforce.com/'+recordId); 
    
         return pg;  
    }

 

venkatsforcevenkatsforce

Shankar,

 

Its also showing null in addressbar  https://ap1.salesforce.com/null

Chamil MadusankaChamil Madusanka

Then there is a issue with the parameter. Isuue is in following line

 

String recordId= apexpages.currentpage().getParameters().get('accId');

 Check your page parameter called "accId"

 

Hit the Kudos button if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.

venkatsforcevenkatsforce

Hi  chamil,

 

Is there any mistake in my VFpage

 

<apex:page controller="showAccountdetails">
 <apex:form >
   <apex:pageBlock >
    <apex:pageblockTable value="{!account}" var="acc">
      <apex:column value="{!acc.Name}"/>
      <apex:column value="{!acc.Phone}"/>
      <apex:column value="{!acc.Industry}"/>
      <apex:column headerValue="Action">
      <apex:commandButton value="Details" action="{!showDetails}">
      <apex:param name="accId" value="" assignTo="{!accId}"/>
     </apex:commandButton>
      </apex:column>
    </apex:pageblockTable>
   </apex:pageBlock>
 </apex:form>
</apex:page>

Chamil MadusankaChamil Madusanka

Try following code with your visualforce page

public class showAccountdetails
{
    public PageReference showDetails()
    {
         //String recordId= apexpages.currentpage().getParameters().get('accId');
        // for(Account ac:[Select Id,Name from Account where Id=:id])
         PageReference pg = new PageReference('/'+accId);
		 pg.setRedirect(true);
       // PageReference pg= new PageReference('ap1.salesforce.com/=+{Id}'&retURL=%2F'+recordId );
         return pg;  
    }
 
    public String accId { get; set; }
    public List<Account> account { get; set; }
    public showAccountdetails()
    {
       LoadAcc();  
    }
    
    public void LoadAcc()
    {
      account = [Select Name,Phone,Industry from Account];
    }
}
mcrosbymcrosby

It doesn't look like you're setting the accId value.  Try:

 

<apex:param name="accId" value="{!acc.Id}" assignTo="{!accId}"/>

 

Shiv ShankarShiv Shankar

Can you post URL, when you are on your custom visual force page. I mean page which calls the controller method - (showDetails) with command button, on that time what is your URL.

venkatsforcevenkatsforce

Url is  https://ap1.salesforce.com/null on the time of calling Showdetails method......

venkatsforcevenkatsforce
I use like this in commandbutton and got the o/p....
<apex:commandButton id="aid" action="{!URLFOR($Action.Account.view, acc.id)}" value="Details"></apex:commandButton>
This was selected as the best answer