i am using Custom button & links in List view of Object and on click of button i am executing javascript to redirected to new page and its works fine in my DE but when i install that package in sandbox it gives me visualforce error that page not found, i know that this is because use of Namespace prefix, because namespace prefix is not attached in newly created URL. i can find the way if i get the way of getting namespace and salesforce instance or should i use another way(i don't have second option as i am new to salesforce)

1 Answer 1


I'm assuming the resolution of Namespace is a build time dependency rather than runtime, as it is unlikely to change dynamically. You can therefore add a static reference to the Package Namespace, rather than attempting to resolve at runtime.

Navigate to Setup > Installed Packages

Click on the Package you've installed and are referring to. You will be able to see the Namespace Prefix here. Use this when referencing the page.

So if the Namespace Prefix is PKG and the VF Page is called VFPage, the URL should be


i.e. /apex/NameSpace__PageName

  • 1
    in that case should i need to change that at all occurrences where i have used the page? Commented Dec 5, 2012 at 11:29
  • Yes, that is right. It should be prefixed with the Namespace in the destination org. Commented Dec 5, 2012 at 11:58
  • 1
    This is the correct answer. For all Custom Buttons and Links, you will need to hardcode the package namespace into your URL's. In the rest of your application, use URLFOR($Page.VFPage) whenever possible to avoid having to hardcode the namespace (to increase code portability), as Visualforce will automatically prepend the prefix of the namespace the code was saved in.
    – zachelrath
    Commented Dec 5, 2012 at 12:21
  • heartly appreciate it Commented Dec 5, 2012 at 12:39
  • If you need the namespace dynamically you can also use the AJAX toolkit to query the NamespacePrefix field on the ApexClass object.
    – Phil B
    Commented Sep 8, 2014 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .