I'm trying to get the community site url, using the ConnectApi in a lightning component, with a SystemAdmin it works fine, but not with any other profile.

Here is my code

final Network myNetwork = [SELECT Id FROM Network WHERE Name ='NET NAME'];
final ConnectApi.Community  myCommunity = ConnectApi.Communities.getCommunity(myNetwork.Id);

The other profile has access to:

  • Apex REST Services
  • API Enabled

Do I need to add another permission?ßß

  • is apex class sharing or without sharing? – Pranay Jaiswal May 2 '19 at 9:13
  • without sharing. – Mo Hamada May 2 '19 at 9:14

From docs mentioned here :

You will only get Ids of the Communities the running user has access to.

You have to Give that profile access to that community. In other words, you have to make that user member of that community to allow him to post.

You can add that profile in the community by going to

Setup -> Communities -> You Community -> WorkSpaces -> Adminsitation -> Member and chose the selected profile.

  • It works now. Many thanks! – Mo Hamada May 2 '19 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.