Skip to content

Instantly share code, notes, and snippets.

@lukethacoder
Last active October 6, 2020 23:06
Show Gist options
  • Save lukethacoder/ad10f417e9e4835405d25ce991d7874c to your computer and use it in GitHub Desktop.
Save lukethacoder/ad10f417e9e4835405d25ce991d7874c to your computer and use it in GitHub Desktop.
snippet to get a list of Salesforce Communities in APEX
List<Network> communities = [ SELECT Id, Name, UrlPathPrefix, Status FROM Network ];
for (Network community : communities) {
System.debug(community.Name + ': ' + community);
}
// or via Connect API
List<ConnectApi.Community> communitiesConnect = ConnectApi.Communities.getCommunities().communities;
for ( ConnectApi.Community community : communitiesConnect) {
System.debug(community.name + ': ' + community);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment