Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukethacoder/ee2a95ce9f52bfe412f0ff99d17065cd to your computer and use it in GitHub Desktop.
Save lukethacoder/ee2a95ce9f52bfe412f0ff99d17065cd to your computer and use it in GitHub Desktop.
Apex code to query a list of communities and their high level metadata
ConnectApi.CommunityPage queryAllTheCommunities = ConnectApi.Communities.getCommunities();
System.debug('queryAllTheCommunities ' + queryAllTheCommunities.communities);
for (ConnectApi.Community community : queryAllTheCommunities.communities) {
System.debug('--------------------------------------------------');
System.debug('id ' + community.id);
System.debug('name ' + community.name);
System.debug('description ' + community.description);
System.debug('siteUrl ' + community.siteUrl); // https://your-salesforce-sites-url.cs46.force.com/custom_site
System.debug('url ' + community.url); // /services/data/v48.0/connect/communities/0DB9A0000003eW9LWC
System.debug('urlPathPrefix ' + community.urlPathPrefix); // custom_site
System.debug('status ' + community.status);
System.debug('templateName ' + community.templateName);
System.debug('--------------------------------------------------');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment