Loading
Salesforce Help 사이트 “Help Agent powered by Fin” 도입 안내더 많이 읽기
Tableau 고객 대상: Tableau를 이용하는 고객이 Help 사이트에서 사례(케이스)를 등록할 수 없는 경우의 대체 수단더 많이 읽기
Slack 관련 문의처가 Salesforce Help로 통합 및 변경됩니다.더 많이 읽기

Get Community ID using Apex

게시 일자: Jun 25, 2026
상세 설명

When building Apex code that needs to identify specific Experience Cloud sites (formerly known as Communities), you can retrieve the unique Site ID for each site programmatically. The ConnectApi.Communities.getCommunities() method returns a list of all Experience Cloud sites the running user has access to, including their IDs, names, and URLs.

When to Use This

Retrieving Experience Cloud Site IDs programmatically is useful in the following scenarios:

  • Routing users to a specific Experience Cloud site based on their profile or context
  • Generating site-specific URLs for links or redirects in Apex code
  • Filtering data by site membership in SOQL queries that reference site IDs
  • Debugging or verifying which Experience Cloud sites are accessible to a given user
솔루션

How to Retrieve Experience Cloud Site IDs Using Apex

Run the following statement in the Developer Console's Execute Anonymous window, or include it in a debug log for review. The statement calls the getCommunities() method from the ConnectApi.Communities class, which returns a CommunityPage object containing a list of Community objects.

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

After running this statement, open the debug log and search for #####. The output includes a list of ConnectApi.Community objects. Each object contains the following properties:

  • id: The unique ID of the Experience Cloud site (formerly Community ID)
  • name: The display name of the site
  • siteUrl: The public URL of the site

You can use the id value in subsequent Apex logic to reference or filter by a specific Experience Cloud site.

Knowledge 기사 번호

000386512

 
로드 중
Salesforce Help | Article