Updating Hard-Coded References in your Salesforce Org

At times administrators and developers think it’s a good idea to hard code salesforce instances into their code, email templates or other parts of the application. I have went through three production refreshes in my career which were all impacted by this behavior. The hyperlink in an email template will look something like https://na22.salesforce.com/id.

Salesforce Knowledge Article Number 000230820 Updating Hard-Coded References explains what hard coded references are and how to find them in your org.

https://help.salesforce.com/articleView?id=Updating-Hard-Coded-References-FAQ&type=1

Quoted right from the Salesforce Article 000230820.
“3. How can I update hard-coded references using Force.com IDE?
Follow the steps below to update hard-coded references* in your org and your org’s metadata (setup or customer code):

i. Create a new Force.com Project:
1. Go to File > New > Force.com Project
2. Provide a name for your project, enter your login credentials for the org, and then click “Next.”

ii. Choose the project contents:
1. Select metadata components, then click “Choose.”
2. On the next screen for metadata components, select the field’s required then click “OK.”

a. At a minimum, we suggest selecting the following: email templates, home page components, web links, workflow, triggers, classes, visualforce pages, and tabs.

3. Please keep in mind that you can only pull 1500 components at a time. If you need to pull more metadata, we recommend dividing your work into multiple projects.
a. If you exceed the limit for number of components, you will receive this error message: “LIMIT_EXCEEDED: Too many files retried in a single retrieve call, limit is 1500.” The Metadata API, which the Force.com IDE uses to communicate with the server, enforces these limits per each deploy/retrieve transaction.

iii. Once you have created your project, press Ctrl-H to perform a search.
1. Search for the name of the instance that your org resides on, for example: NA4. See Figure 1 below.
a. If you have multiple projects open, right-click on each project you don’t want to search on and choose “Close Project” or modify the search criteria so that you have a “working set” to minimize the files you’re searching on.”

It is not best practices to hard code instances in your org.

Fix :

Use the relative URL. Instead of using https://na22.salesforce.com/001/e?retURL=/home/home.jsp use /001/e?retURL=/home/home.jsp. Leave out the Instance or host part of the URL.

Secondly, https://login.salesforce.com/001/e?retURL=/home/home.jsp will also work.