How to redirect to default namespace vf page from managed package vf page?

Question

If I’m on a managed package page, how can I link to a visualforce page in the default namespace without hardcoding the instance?

Background

I’m building a skuid page that has a custom action that sends users to a visualforce page. If I specify the relative URL for the visualforce page, e.g. /apex/MyPage, the redirect stays in the skuid namespace, i.e. https://skuid.<pod>.visual.force.com/apex/MyPage, which gives a URL not found error.

I’m able to get things working if I specify the absolute url, i.e. https://<pod>.salesforce.com/apex/MyPage, but I’m hoping to avoid hardcoding the absolute URL.

I’ve searched through all the Skuidify manuals and haven’t been able to find any solutions there. Hoping the community has some tips here.

Answer

I realize this is a little late in coming, but for posterity’s sake, if you append the namespace to the front of your visualforce page name, salesforce will make sure it gets the proper namespace in the full url.

So if you want your action to go to /apex/MyPage, you would do this: /apex/c__MyPage

If you’re linking to something in a managed package you need to use that namespace instead: /apex/mpnamespace__MyPage

Hope that helps!

PS: We should definitely add this to our docs. It shall be done.

Attribution
Source : Link , Question Author : Ralph Callaway , Answer Author : SkuidJohn

Leave a Comment