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
JoeyDJoeyD 

Redirect to parent record when saving child record...

I've added the following extension to a visualforce page. The page's object is a child of Opportunities. After saving a record in this child object, I'd like to be redirected back to the parent record.

 

I don't know how to get the parent Opportunity record ID to reference in the PageReference method.

 

(I know my custom object is called TestParent... this is because it is actually the parent of another custom object, TestChild. :smileytongue: )

 

 

public class testParentSave {

public TestParent__c parent {get; set;}

public testParentSave(ApexPages.StandardController controller) {
parent = (TestParent__c) controller.getRecord();
}

public PageReference save() {
insert parent;
PageReference pr = new PageReference('/'+TestParent__c.Opportunity__c);
pr.setRedirect(true);
return pr;
}
}

 

 

JoeyDJoeyD

No one knows?

 

I've started in on the Apex Code Developer's Guide, but haven't across this yet...