Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukethacoder/135d94c5dd83ca84241ef076a7e31c32 to your computer and use it in GitHub Desktop.
Save lukethacoder/135d94c5dd83ca84241ef076a7e31c32 to your computer and use it in GitHub Desktop.
APEX snippet to give the current user access to the community (will bring back the `Workspaces | Builder` buttons)
String endpoint = URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v47.0/sobjects/NetworkMemberGroup';
HttpRequest httpRequest = new HttpRequest();
httpRequest.setEndpoint(endpoint);
httpRequest.setMethod('POST');
httpRequest.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
httpRequest.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Change network id and profile/permission set Id
httpRequest.setBody('{"NetworkId":"0DBB00000004d57","ParentId":"00eB0000000fegYIAQ"}');
Http http = new Http();
HttpResponse httpResponse = http.send(httpRequest);
@lukethacoder
Copy link
Author

may need to adjust the API version in the endpoint URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment