• Mike E
  • NEWBIE
  • 0 Points
  • Member since 2021
  • Senior Salesforce Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,

I want to get community URL from apex class.
Is there anyway to get it?

I have been try the following, but I can't get absolute URL.

test -1- the following source only work when debug in developer console.
Network myNetwork = [SELECT Id FROM Network WHERE Name ='myCommunityName' ];
ConnectApi.Community  myCommunity = ConnectApi.Communities.getCommunity(myNetwork.id);
System.debug('MyDebug : ' + myCommunity.siteUrl);

test -2- the following result have extra word /login.
Network myNetwork = [SELECT Id FROM Network WHERE Name ='myCommunityName' ];
System.debug('MyDebug: ' + Network.getLoginUrl(myNetwork.id);