3

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)

2

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

/apex/PKG__VFPage

i.e. /apex/NameSpace__PageName

| improve this answer | |
  • 1
    in that case should i need to change that at all occurrences where i have used the page? – Axaykumar Varu Dec 5 '12 at 11:29
  • Yes, that is right. It should be prefixed with the Namespace in the destination org. – techtrekker Dec 5 '12 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 Dec 5 '12 at 12:21
  • heartly appreciate it – Axaykumar Varu Dec 5 '12 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 Sep 8 '14 at 14:50

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.