You need to sign in to do that
Don't have an account?

Urgent- Redirect from Child page to Parent object
Hi,
I have a Master-Detail relationship between Opportunity and Deal.
When i save a record in Deal page(Visualforce page), i want it to get redirected to the Opportunity detail page.
Its kind of urgent, please let me know how can i do this.
Thanks..
Hi,
You can use a Pagereference class.
For example:
After Deal record creation you can write below code to navigate user to Oppoertunity Detail Page.
Pagereference page = new Pagereference|('/'+opp.Id); // opp.Id is the Id of an Opportunity records
page.setRedirect(true);
return page;
Thanks,
Devendra
Thanks for the reply...
Can you please tell me what will the query.
Below is my code:
public PageReference value() {
stdCtrl.save();
Id ide = ApexPages.Currentpage().getParameters().get('id');
Opportunity opp = [select id,name from Opportunity where Id =: ide];
Pagereference page = new Pagereference('/'+opp.Id);
page.setRedirect(true);
return page;
}
I think you need to use the following code; I am not sure which one is the parent which one is child, but this can be a good reference I hope.
public PageReference value() {
stdCtrl.save();
Id ide = ApexPages.Currentpage().getParameters().get('id');
Deal__c dl = [SELCT Deal__r.OpportunityID FROM Deal WHERE Id =:ide];
Pagereference page = new Pagereference('/'+Deal__r.OpportunityID);
page.setRedirect(true);
return page;
}