I am using the below method in button tag in visualforce page. After insert i want to redirect to the parent record detail page. currently it is not happening. Please help.

public class BIAcontroller
    public BIAcontroller(ApexPages.StandardController controller)
        account=new BIA__c();
        // other constructor operations

    public BIA__c account{ get; set; }
    // other properties

    public PageReference processSelected() 
        //do stuff
        insert account;

        PageReference nextPage = new PageReference('/' + account.id);
        // nextPage.setRedirect(true);
        return nextPage;
  • You are currently redirecting to a list view (PageReference('/a0U/o');). If this is the right moment/condition you want to redirect, replace it with PageReference('/'+account.id);. Also you should clarify what you mean by parent object.
    – dzh
    Jun 12 '15 at 3:21
  • BIA__c account = new BIA__c is the parent one and Team__c is the related list to BIA__c.After the operation is finished it should redirect to newly created BIA__c record.
    – hellraizer
    Jun 12 '15 at 4:53
  • Hi.. I have updated my controller. After modifying that part , the page is not redirecting to the record. Please help.
    – hellraizer
    Jun 12 '15 at 4:59
  • Looks like you are not inserting bia__c, perhaps before returning it, insert it first, then redirect to it's id.
    – dzh
    Jun 12 '15 at 5:01
  • insert account; this line is inserting BIA__c record then updating Team__c record then i am redirecting.Please help me in understanding..
    – hellraizer
    Jun 12 '15 at 5:09

Generally if I have an SObject and I want to redirect to it via PageReference, I will use the following:

SObject record; // can be of any type
PageReference view = new ApexPages.standardController(record).view();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.