Get Site URL from apex
Is there a way to get the URL of a salesforce site from apex
I need this to send the url in an email message, so the apex is run outside of the site context. I basically want to expose a link to my salesforce site in an email message. But so far I haven't found a way to do that
I would prefer not hard coding the url in apex
Are Sites available in some table you can query? Like `select NamespacePrefix, Name from ApexPage limit 10`?
yes, you can query them: `[SELECT Name, Status, Subdomain FROM Site]` this only gives me the subdomain in subdomain.force.com, this should work well when installed on a production org, but when using the app on a dev org / sandbox you get a different URL for example: `http://subdomain.na14.force.com/sitename`
This doesn't seem to be possible from apex, I ended up trying the different ways described above, and decided to go with a Custom Setting. I added the Custom Setting
Site URLwhich needs to be filled in every time when the app gets configured.