Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

When I am creating an Unmanaged Package and Test it in demo org - It works fine as I required, but when I create Managed Beta of the same package and Install it in Demo org and Test, It does not open VF page and gives an error - VF Page not found.

VF page is available in components of installed package and everywhere, When I manually change URL by preceding it with NAMESPACE then it works or open VF page manually in demo org it open with ease which does not happen when I try to open this on button click.

I have written URL Formula on List Button click.

What should be the issue ? What I am missing ?

This is my Button Formula -

  {!IF(
       $Organization.name='My Orgnization name',
       (
        {!URLFOR("/apex/MYVFPAGENAME?"+ 
              IF(Account.Id!=NULL, "aid="+ Account.Id+"&", "") + 
              IF(Contact.Id!=NULL, "cid="+ Contact.Id+"&", "")
         )}
       ),
       (
        {!URLFOR("/apex/namespace__MYVFPAGENAME?"+ 
              IF(Account.Id!=NULL, "aid="+ Account.Id+"&", "") + 
              IF(Contact.Id!=NULL, "cid="+ Contact.Id+"&", "")
         )}
       )
     )}

EDITED :

var parameters = ('{!Account.Id}'!=null)?'aid='+'{!Account.Id}'+'&':'' + ('{!Contact.Id}'!=null)?'cid='+'{!Contact.Id}' +'&':'';

var url = '/apex/MYVFPAGE?'+ parameters;
var namespaceurl= '/apex/Namespace__MYVFPAGE?'+parameters;


if ("{!$Organization.Name}".indexOf("My Orgnization Name") > -1) {
window.location.href = url;
} 
else {
alert(namespaceurl);
window.location.href = namespaceurl;
}
share|improve this question
    
Have you added the namespace of the managed package to the URL? –  Bob Buzzard Aug 28 at 6:58

1 Answer 1

As Bob said, have you tried:

{!URLFOR("/apex/namespace__MYVFPAGENAME?"+ IF(Account.Id!=NULL, "aid="+ Account.Id+"&", "") + IF(Contact.Id!=NULL, "cid="+ Contact.Id+"&", "") )}

This of course will mean that your button no longer works in your package dev. org(s) as the namespace is not present there.

I'm not sure there's an elegant solution for this problem, but I have seen Company Name used to get around this problem.

That would look something like this:

If (
    Or (
        {!$Organization.Name} = 'Package Source Org. 1',
        {!$Organization.Name} = 'Package Source Org. 2',
        {!$Organization.Name} = 'Package Source Org. 3'
    ),
    (
        {!URLFOR("/apex/MYVFPAGENAME?"+ 
        IF(Account.Id!=NULL, "aid="+ Account.Id+"&", "") + 
        IF(Contact.Id!=NULL, "cid="+ Contact.Id+"&", ""))}
    ),
    (
        {!URLFOR("/apex/namespace__MYVFPAGENAME?"+ 
        IF(Account.Id!=NULL, "aid="+ Account.Id+"&", "") + 
        IF(Contact.Id!=NULL, "cid="+ Contact.Id+"&", ""))}
    )
)

So for your package orgs the button will direct to the non-namespaced page, but when installed in a client / demo / etc. org where {!$Organization.Name} is different it will direct to the namespaced page.

As I said, it's not elegant but I'm not sure there's a better way around it.

Edit:

Here's a working solution. Change the button to a Javascript button, and then use Javascript to check Org. Name & direct accordingly.

if ("{!$Organization.Name}".indexOf("Package Source Org. X") > -1) {

    window.location.replace("/apex/VisualForcePage");

} else {

    window.location.replace("/apex/namespace__VisualForcePage");

}
share|improve this answer
    
This could be the solution, but it didn't worked again in my Demo/Client org. I have Updated the question with changes I have done according to above answer –  Nilesh Mendhe Aug 28 at 10:04
1  
OK I tested it, slight change needed. I'll edit my post now. –  DavinC Aug 28 at 13:22
2  
Where there's a will, there's JavaScript. –  sfdcfox Aug 28 at 14:05
    
OMG ! I worked on that too. Edited the new Code ! (and it seems that its not app's wish wheather its JScript or Apex) –  Nilesh Mendhe Aug 29 at 12:43
    
Did the JS code work? –  DavinC Aug 29 at 12:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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