Salesforce | Invoking a Visualforce page in a managed package

|
| By Webner

Remember one thing i.e to use __ (double underscore) after package name. Suppose you have a Visualforce page that uses custom controller. Visualforce page name is Upload_a_File. You have created a button on this page to choose a file and then upload this file to Amazon S3 or some other location.
URL of this page is :  /apex/Upload_a_File

Problem:

Everything works fine in your developer org. The problem comes when you create a managed package and install it in a destination org. When you press the button, an error message shows up :

‘Page Upload_a_File does not exist’

However, if you enter following URL directly into the browser, page successfully shows up:

https://my_namespace_prefix.na6.visual.force.com/apex/Upload_a_File

Reason and Solution:

Namespace prefix is not automatically pre-pended for the URL specified behind click of the custom button, which is the reason for above error.

To solve it use this Javascript code on click:

window.parent.location.href='apex/mynamespaceprefix__myVFPage';

Leave a Reply

Your email address will not be published. Required fields are marked *