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
AdamJonesAdamJones 

Site name reported incorrectly in sandbox

I'm inhereting a SF codebase that has some apex code that doesn't work in the sandbox environment.   The reason is that the code creates a link in a visual force page that has a url to a custom page that is under the organizations "sites" configuration.
 

The problem is that the url created is always wrong.    The prefix at the very begining of the url is to the live server's custom site url but that is compltelye different when using the sandbox.
 

I can't find a single way either via system methods or queriying the database to obtain the site url prefix on our sandbox.        I thought that "SELECT Subdomain from Site" might work but it returns the live systems site prefix.   

I've seen a somewhat unreliable solution in a forum post somewhere that took the user's email address, obtaining the last part after the final full stop and using that as a way to determin the prefix for the site url as these two things are often the same. However, often is the key point here, not always.  


At the end of the day the "Default Web Address" as it's called in sites configuration page is determined by the SF system, is it really not possible to query this somehow!?