I am using Salesforce Community and I have network Id of the community but I don't know how can I get Base URL of my community. Any one know how can I get my community base URL using its id in apex as a internal user.

Is there any other way in which salesforce internal user can get the base URL of all his community in the apex also i don't find any object in which Community Base URL is stored. I checked network sObject but it only store community path prefix not the complete URL so how can i get the base URL for my community?


finally i found the answer i use

Network.getLoginUrl('Pass Community id here')

in this way i found the login page URL for the community and then break the URL and use as per my Requirement.

| improve this answer | |

On a Visualforce page controller/extension, you can always grab the base URL using the URL class methods in apex:


URL Class documentation

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.