[SalesForce] Accessing a external VF page from managed package

I've installed a managed package in an org. Now, in this org, I've created another VF page. Now I want to write a piece of code in my one of controller which is the part of managed part that will redirect to this new VF page. Is this possible? Since newly created VF page is not a part of managed package. Any thoughts?

Best Answer

You can reference a visualforce page which resides outside of your managed package in controller which resides inside the package, by not using Page.VisualforcePageName, and instead use new PageReference('/apex/VisualforcePageName'); because say if you wanted to reference a Page inside your managed package, you would add the namespace: new PageReference('/apex/packageNameSpace__VisualforcePageName');

You won't get a compile error in your managed package when you do it this way, because the existence of your page is evaluated at runtime, and would display an error when the page wouldn't exist.

Take a look at a question I asked, which might be helpful to you:

Make visualforce page (pdf) available outside managed package

Related Topic