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
SeanMSSeanMS 

Apex Page Redirection

Hello,

 

I have added a section to the Account Detail Page that points to a VisualForce Page. From the VF Page I have a button that the user needs to click and after some operations I want the current page to redirect to a Contact Page. This is working, but the new page gets loaded into the small section on the Account Detail page instead of the full window. How can I reload the entire window?

 

Here's the code at the bottom of my Apex method that gets called when the button is clicked...

 

 

PageReference newContactPage = new ApexPages.StandardController(newContactRec).view(); newContactPage.setRedirect(true); return newContactPage;

 

Thanks!

 

 

 

 

Cool_DevloperCool_Devloper

Hi Sean,

 

I suggest instead of re-directing through the controller, you can do the same through JS!

If you have the ID of the contact on your Detail page, then you can build a URL and call a JS function onclick of a button/link from ur VF section.

Cool_D

SteveBowerSteveBower

 

 To Clarify, I think you're saying your VF page is rendered in an iframe inside the standard Detail page.  Your VF page is correctly redirecting, but you want the outside, "containing", page to redirect, not just the interior.

 

If that's correct I think you're going to run into difficulty because the interior frame with the VF page is being served from one site within Salesforce, and the  standard detail page is from another site.  I think you're going to run into the cross site scriptingbrowser limitation which is there for security purposes.

 

In a similar vein, oftentimes we don't know how large a VF page will be until you build it.  (Sometimes you include a lot of rows in a list, for example, sometimes just a few).  When you include the VF page in the Detail page you have to specify a size for the window.  If your VF page is too large, you end up scrolling within that region to see it all.

 

One would hope that there was a way from the VF page to tell the parent page what the "right" dimensions are so that you get get away from the scrolling.  As near as I'm aware, there is no solution to this at the moment.  (With VF or Javascript)

 

I think the only way to accomplish this is to use VF to render the entire Detail page as well as the bit that you're currently doing.  Then you can navigate away from the page and it will effect the entire page.  (If you're just doing a standard Detail page, and you can append your bit on the bottom instead of in the middle, that should be pretty easy... )

 

Sorry, hope this helps,  Steve.

 

SteveBowerSteveBower
I should note, I could be wrong here, perhaps I'm missing something and Cool-D could elaborate?  :-)  Thx -S
Cool_DevloperCool_Devloper

I think you're right Steve.

This cross site security issues might not let JS/VF work!

So, the only other option is to re-build the page entirely in VF as you said.

Cool_D 

SeanMSSeanMS
Thanks for your feedback! That's too bad :( As another work-around, but not that appealing, perhaps I can try to open the newly created Contact edit page in a new window? Any thoughts on this approach?
Cool_DevloperCool_Devloper

Sean,

Just out of curiousity, did you try using JS?

in case it did not work as expected, then i think opening a new window should work!

Cool_D