The current documented way to retrieve the ID of a given community is via the ConnectAPI class.

While this works, the ConnectAPI class has a special requirement: any use of ConnectAPI methods requires (SeeAllData=True) on related test code.

This flies in the face of best practices when it comes to writing test code, and I'd like to avoid it if possible.

Currently, my code's only use of ConnectAPI is ConnectApi.Communities.getCommunities(). Is there a SOQL query or some alternative class I can use and avoid the SeeAllData requirement?

1 Answer 1


[SELECT id, name FROM Network]

from the SObject api, thanks to Lacey Snr and this thread.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .