When I develop a package and use a Visualforce page with additional parameters as custom button, URL button link doesn't work in subscriber org.

For example, my page has name MyBeautifulPage and URL button link /apex/MyBeautifulPage?param=Value works great in Developer Edition org where package is developed, however, in subscriber org that button doesn't work.

Looks like it is need to determine the current URL and instance name to transform the URL correctly from eu6.force.com to package-name.eu6.visual.force.com, from archie--devarchie.cs13.my.salesforce.com to archie--devarchie--package-name.cs13.visual.force.com, from production.my.force.com to production--package-name.eu10.visual.force.com.

Looks like I can get InstanceName from Organization by querying [select InstanceName from Organization], probably I could get current URL by System.URL.getSalesforceBaseUrl().toExternalForm(), however it is not clear how to process it altogether correctly.


Looks like there is a hack to make this simplier.

It is enough to prefix page name with package name like following:


and Salesforce will redirect to the correct link.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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