+ Start a Discussion
cnp_nareshcnp_naresh 

Custom button url issue

HI Every one,

 

     I created a custom button in contacts standard object.I given the url, as /apex/virtualterminal?ContactId={!Contact.Id}  .When user clicks on this button it displays a page with this url  https://cnp.na3.visual.force.com/apex/virtualterminal?ContactId={!Contact.Id} . I created a managed package and installed in a developer account for testing.

 

     When I click on the custom button it displaying a page with url https://c.na3.visual.force.com/apex/virtualterminal?ContactId={!Contact.Id} . and its giving a error, "Page virtualterminal does not exist".I am unable to understand why cnp is changing to c in the url. I did a lot search but did not find the solution.please help me.

 

Thanks,

Naresh B

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

The actual problem is not this. Host (cnp,c,na6,na7) can be different but the problem is here "/apex/virtualterminal?ContactId={!Contact.Id}". As you have created a managed package so there must be a namespace defined.

 

So to get this URL proper you need to append the namespace before the page name like this :

 

"/apex/YourNameSpace__virtualterminal?ContactId={!Contact.Id} "

 

Now the thing is if we have package the code of button in managed package then we can not change this, so what exactly we need to do is, create a custom setting of "Hierarchy" type and put the namespace there.

 

Lets say I have created a custom setting name test and field "Namespace" where I will keep my name space.

 

Now I will fetch this namespace in button like this :

 

"/apex/{!$Setup.test__c.Namespace__c}virtualterminal?ContactId={!Contact.Id} 

 

 

Let me know if there is any problem using this approach.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

Ankit AroraAnkit Arora

The actual problem is not this. Host (cnp,c,na6,na7) can be different but the problem is here "/apex/virtualterminal?ContactId={!Contact.Id}". As you have created a managed package so there must be a namespace defined.

 

So to get this URL proper you need to append the namespace before the page name like this :

 

"/apex/YourNameSpace__virtualterminal?ContactId={!Contact.Id} "

 

Now the thing is if we have package the code of button in managed package then we can not change this, so what exactly we need to do is, create a custom setting of "Hierarchy" type and put the namespace there.

 

Lets say I have created a custom setting name test and field "Namespace" where I will keep my name space.

 

Now I will fetch this namespace in button like this :

 

"/apex/{!$Setup.test__c.Namespace__c}virtualterminal?ContactId={!Contact.Id} 

 

 

Let me know if there is any problem using this approach.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
cnp_nareshcnp_naresh

Thanks for the help.It greatly worked.But I given "/apex/YourNameSpace__virtualterminal?ContactId={!Contact.Id} " and made a new package and installed. Its working well.But I didnt understand about "Hierarchy" and custom settings.

 

Thanks,

Naresh B

Ankit AroraAnkit Arora

You have provided the namespace in the button code, it will work fine on the organization from where you are creating the package and where you are installing it.

 

I have provided you the scenario with which you can make it bit general, like if I develop on one developer edition and to package those components in managed package I use another developer edition because once the component is packaged they get freezed in managed package. To keep the flexibility I use two different developer editions.

 

But in your scenario only appending the namespace in button will work, that was just FYI.

 

So if the post helped you please mark it as solution.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

cnp_nareshcnp_naresh

Thanks a lot for your great help. Can you please let me know how to create custom setting to define name space.Where I need to create it and how I need to create it.

 

Thanks,

Naresh 

 

 

Ankit AroraAnkit Arora

As I have already told you create a custom setting with name Test (test__c) and and field NameSpace(Namespace__c) in it.

 

Now put the namespace value ('MyNameSpace__') in the custom setting and keep your button code like this :

 

"/apex/{!$Setup.test__c.Namespace__c}virtualterminal?ContactId={!Contact.Id} 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page