0

I have a visualforce page which shows list of a custom object records in which id of another customobject id is passed in the url .One column shows the Account name which has lookup relationship with the custom object.I have one button mycommandbutton in each row and on click this will show the contact records for that account only in a different vf page.

I want to add one back link in my 2nd vf page so that it will go to the first vf page. My first vf page contains the customobject record id in the url and 2nd one account Id.i am not sure how to capture the customobject record id from the 2nd page so that it will navigate to first page again.

<apex:commandButton value="mycommandbutton" action="{!$Page.my2ndpage +'?id=' +obj.Account__r.Id}" immediate="true">
1
  • What is your first page url looks like?
    – highfive
    Commented Jul 18, 2014 at 16:36

1 Answer 1

2

You can pass the custom object Id as well into the second page via the query string like you are already doing it for the Account Id. Then use that in the second page controller to redirect the user to first page.

<apex:commandButton value="mycommandbutton" action="{!$Page.my2ndpage +'?id=' +obj.Account__r.Id+'&cust_id='+cust_obj_id}" />

In the second page controller use this custom object Id as below to redirect back into the first page (assuming getBack() is your method triggered to go back to the first page).

public PageReference getBack(){
  String accname = ApexPages.currentPage().getParameters().get('cust_id');
  PageReference firstPage = new PageReference('/apex/YourFirstPage?id='+accname);
  firstPage.setRedirect(true);
  return firstPage;
}

You must log in to answer this question.

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