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
imishraimishra 

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..

Devendra@SFDCDevendra@SFDC

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

imishraimishra

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;

    } 

Jerun JoseJerun Jose
Your code snippet looks correct. If you are asking how to pass the correct filter value in the query, I will need to see rest of the code.
OnurKOnurK

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;

    }