I'm looking for a way to get the registered Force.com domain from Apex. At the moment I just want to check if there is a domain or not.
This is the domain you register once, when trying to create a public site.
I know you can find the subdomain for a site by querying the field subdomain
in the object Site
, however, it is possible that a domain is registered but a Site wasn't created. How can I figure out the force.com domain in that scenario?
Attribution to: pjcarly
Possible Suggestion/Solution #1
This currently isn't exposed in Apex.
Attribution to: Ryan Guest
Possible Suggestion/Solution #2
You might be able to do it by using the getHeaders() method on PageReference class. I've not tested this, but thats where I'd start.
Expose a stupid simple (empty) visualforce page publically, and create a page reference to it. The getURL() method will return the relative url, but hte headers will likely have the full url.
Let me know if it works.
Attribution to: Kevin P
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32388