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.