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
Andrea SloanAndrea Sloan 

How to replace hard coded references with Eclipse?

I'm in Eclipse. I've set up a Force.com project labeled hard coded links. The metadata refereces my CS21 instance of my Sandbox. I'm trying to see if it'll pull up any hard coded links with that org reference. I type in CS21 but no results come up. Since CS21 is not a field or a report but just an instance name, I don't know how to make sure that gets included in my metadata. how would I even go back to edit the metadata to make sure?  I know I have a few hard coded linkes as I had ran a lightning test.
I'm not sure how to run a query to find my hard coded links in Eclipse and then what do to repalce them  replace them so they are  no longerhard coded to the instance?  know it's best for the hard codes not to point directly to an instance in case salesforce doesn an instance refresh and put it on another server but I don't know how to change the pointing to what? I also read up about creating my own salesforce domain which would handle this but I still don't know how to direct my hard coded links to a new domain and what to do if I remove the instance name (i.e. CS21)
Best Answer chosen by Andrea Sloan
Waqar Hussain SFWaqar Hussain SF
For setting up custom domain, see to the below article. 
https://help.salesforce.com/articleView?id=000205653&type=1

All Answers

Waqar Hussain SFWaqar Hussain SF
Hi Andrea,

You can search the hardcoded link in eclipse and then can replace the hardcoded links on the instance using URL class. see example
 
// Get the base URL.
String sfdcBaseURL = URL.getSalesforceBaseUrl().toExternalForm();
System.debug('Base URL: ' + sfdcBaseURL );

For more information see the below URL class.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_url.htm

Let me knwo If you have any question. 

Thanks
Andrea SloanAndrea Sloan
Hi Waqar:

I'm a system administrator and really don't know much about what a URL class is. I read the link you provided but did not understand what it's saying. The three lines that you posted, where exactly would I put them inside Eclipse? Can you show me with a  screenshot? can you explain to me what each line means? To repalce the hardcoded link, don't I jsut need to get rid of everyting in the link prior and including "salesforce.com" and include everything else in the string starting with a " /"? I had gone into each of my links where they are found inside Salesforce to do this. But again, if you could explain to me in more simple terms how to do this from Eclipse that would be great and from the lines you posted, what exactly I needto change and customize to my needs. Finally, how would I then have my own Salesforce domain? How do I do this and make sure all the links (no longer hardcoded) are included in the domain? I was told it's best to have your own domain in Salesforce to not be affected when instances change. is that correct?
Thank you for your help.
Waqar Hussain SFWaqar Hussain SF
Hi Andrea,

please see the below link. This is what you are looking for.
https://help.salesforce.com/articleView?id=Updating-Hard-Coded-References-FAQ&type=1
Andrea SloanAndrea Sloan
Hi Wagar:

I alredy have this document which I've been working off. this is how I knew how many hard codes I had and I then went and removed the hard code. My previous questions were addressed to the developers community wih hopes on getting specific clarifications which i didin't get with this document. it doesn't talk about how to set up my salesforce Domain and how to connect my links to it.
Waqar Hussain SFWaqar Hussain SF
For setting up custom domain, see to the below article. 
https://help.salesforce.com/articleView?id=000205653&type=1
This was selected as the best answer
Andrea SloanAndrea Sloan
Thank you!