function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
imAkashGargimAkashGarg 

URGENT: change in link while deploying

i have a visualfoce page in dev environment with a button pointing to other visualforce page. now when i deployed the page to other environment using change set..... the link was not working in that env.

in the dev env. the link is something like: https://c.cs0.visual.force.com/apex.....

 

and in the other env. it is: https://c.cs12.visual.force.com/apex.....

 

can't i have a common link so that i dont have to manually change them while deploying?

Best Answer chosen by Admin (Salesforce Developers) 
imAkashGargimAkashGarg

Thanks for your suggestions.

 

This worked by simply passing the partial URl to the PageReference,

                  

                  i.e.  '/apex/pageName'

 

Creates a PageReference to any page that is hosted on the Force.com platform.

Here, refers to the Visualforce page located at:

 

http://mySalesforceInstance/apex/pageName

 

Thanks.

All Answers

RjSanchezRjSanchez

You can refer to a visualforce page by calling.

Page.Yourpagenamehere

 

for instance, in my controller I have

public PageReference gotoMyPage() {
    return Page.MyPage;
}

 

The Visualforce page "MyPage" actually lives as https://instance.salesforce.com/apex/MyPage

 

Hope this helps.

imAkashGargimAkashGarg

hey thanx.

 

i did the same thing. we need to return the url of the page. but this url keeps changing on different enviroenments.

i want to write a common url that could be referenced to any environment.

RjSanchezRjSanchez

You may be able to build it in your apex controller by using the headers to get the instance server you are currently on.

 

Consider:

Map<String, String> headMap= System.currentPageReference().getHeaders();
String myInstance = headMap.get('X-Salesforce-Forwarded-To');

myURL = 'http://'+myInstance+'/apex/MyPage';

This only returns the fully qualified domain name of the Salesforce instance, cs9.salesforce.com for me.

so I concatenate the rest of the url in a string.

 

Maybe that can help you. Something to think about at least.

 

Cheers.

aballardaballard

How are you using the url that requires you to hard code the server?  If it is within a visualforce page, you should be able to use the urlfor formula function to generate the url with the correct server....

 

imAkashGargimAkashGarg

Thanks for your suggestions.

 

This worked by simply passing the partial URl to the PageReference,

                  

                  i.e.  '/apex/pageName'

 

Creates a PageReference to any page that is hosted on the Force.com platform.

Here, refers to the Visualforce page located at:

 

http://mySalesforceInstance/apex/pageName

 

Thanks.

This was selected as the best answer