Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to open a normal visualforce page (that is NOT a part of the managed package) from a visualforce page that is IN managed package.

This button I have on the visualforce page in manage package:

<apex:commandButton value="Open" onclick="window.open('apex/MyPage'); return false;" />

The MyPage is NOT in the managed package.

By clicking on the button a new popup window appears, so javascript works well.
But the problem is that I am getting the following error message and no content of the MyPage:

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com.

After some research I've found a difference between URL of the both pages.

Managed package visualforce page with that command button:

https://customDomainName--PREFIX.csXX.visual.force.com/apex/PageInManagedPackage

Another page that should be opened (MyPage, not in managed package) is opened with the same prefix in URL. But if I replace the PREFIX with a c then the page will load without problems:

https://customDomainName--c.csXX.visual.force.com/apex/MyPage          <- this works
https://customDomainName--PREFIX.csXX.visual.force.com/apex/MyPage     <- this not

How you can see the only difference is that external page opened with a prefix in URL could not be shown :(

My question is, what is wrong with my button? Why an "external" page opens with a wrong URL? Is it a managed package "feature"? How can I avoid this?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Issues:

  1. URL No Longer Exists
    • Error is happening because your path to the page is incorrect and is missing the leading / which creates a URL which is relative to the current page rather than relative to the host.
  2. Path to the page outside of the managed package namespace
    • The default VF namespace is c__ and you can specify this in your page path. This allows you to avoid hardcoding a fully qualified URI.

<apex:commandButton value="Open" onclick="window.open('/apex/c__MyPage'); return false;" />

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

share|improve this answer
    
ooh, didn't know about the __c prefix, nice –  executeanon Sep 1 at 18:08
    
WOW! Great hint Mark, didn't know about c__PageName, but this is so obvious! :) Many thanks. –  mast0r Sep 2 at 6:58

I think pages opened from within a managed package must always be fully qualified with the full URL, so your button would have to be:

<apex:commandButton value="Open" onclick="window.open('https://c.csXX.visual.force.com/apex/MyPage'); return false;" />

Obviously, this will give you some challenges to get the correct pod in your URL, but other than that should work.

I believe it is indeed a feature of managed packages.

share|improve this answer
    
I've just tried to hard code the whole correct URL (w/o prefix) to the button and a popup page opens correctly. So the challenge is to generate this URL without prefix dynamically :) Thanks. –  mast0r Sep 1 at 14:43
    
Would a custom setting be dynamic enough perhaps? –  executeanon Sep 1 at 14:56
    
I dont think so. It is not always the same. –  mast0r Sep 1 at 15:05

I'm not sure that this will solve your problem but try this one :

< apex:commandButton value="Open" onclick="window.open('{!$Page.MyPage}'); return false;" />
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.