Print this page

How to get the community ID via apex

Knowledge Article Number 000192853
Description It is not mentioned in any of the Community documentation or Salesforce Apex guides about How to retrieve the Community ID which the running user has access.
Resolution

The correct Community ID can be found if we use the below debug log statement.

System.debug('#####' + ConnectApi.Communities.getCommunities());

 

 Using the above debug statement we can find the list of communities the running user has access to.



 




promote demote