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
Ken Koellner @ EngagewareKen Koellner @ Engageware 

How to get configured Sites domain for Org in Apex

I'd like to get the Sites domain that configured for an org via Apex in order to automate some setup work.  I haven't found a way to do that.  It's probably not there but just in case I missed it in the documentation I figured I'd ask if anyone knows if there's any kind of metadata call to get it.

This is not specific to any one site and VF is not in place so anything that only exists in the context of an executing Site will not work.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ken,

Greetings to you!

I haven't tried it but I suggest you please refer to the below links which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/142278/retrieve-force-com-registered-domain

https://salesforce.stackexchange.com/questions/53201/getting-instance-name-of-org-with-a-domain

https://wedgecommerce.com/how-to-get-site-url-salesforce/

https://salesforce.stackexchange.com/questions/7639/get-site-url-from-apex

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas