Add Community Member
Salesforce stores community membership in object called NetworkMemberGroup. Although Salesforce says ‘create’ allowed on Network Member but seems that not allowed using apex code. No worries, we can make a post REST call for the same:
First add your salesforce base url as remote site setting then add this code as part of your implementation:
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":"0DB900000008Qga","ParentId":"00e90000001uNre"}'); Http http = new Http(); HttpResponse httpResponse = http.send(httpRequest);
- Add community/internal profile id or a permission set as ParentId
- Provide Community id as NetworkId
Set Default Community for a Profile
Salesforce stores community membership in object called Network Affinity. Although Salesforce says ‘create’ allowed on this object but seems that not allowed using apex code. But we can make a post REST call for the same as previously:
String endpoint = URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v47.0/sobjects/NetworkAffinity'; 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":"0DB900000008Qga","ProfileId":"00e90000001uNre"}'); Http http = new Http(); HttpResponse httpResponse = http.send(httpRequest);
- Add community/internal profile id as ProfileId field
- Provide Community id as NetworkId
I know this if off topic but I’m looking into starting my own blog and
was curious what all is required to get set up?
I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet savvy so I’m not 100% positive.
Any recommendations or advice would be greatly appreciated.
Thank you
I have found very interesting ypur article.It’s
pretty worth enough for me. In my view, if alll website owners and bloggers made good content aas you did, tthe
web will be a lot more useful than efer
before.
Fabulous, what a web ite iit is! This web site provides useful
data to us, keep it up.
Way cool! Some very valid points! I appreciate yyou penning this post and the rest of the website is also really good.
Hello everyone, it’s my first visut at this website,
and piece of writing is genuinely fruitful dessigned for me, keep up posting such
articles or reviews.
Hello to every one, since I am genuinely keen of reading this website’s post to be updated regularly.
It carries nice data.
Ohh, its fastidious discussion about this article here at this webb
site, I have read all that, so now me also commenting at this place.
Wayy cool! Some very valid points! I appreciate
you penning this post and tthe rest of the website is aloso really good.
Wow, amazing blog layout! Howw long have you been blogging for?
you made blogging look easy. The overall look of your web site is
excellent,as well as the content.
Way cool! Some veery valid points! I appreciate you pennng this post and the rest of the website
is also really good.
Hello There. I found your blog using google. This
is an extremely well written article. I’ll make sure to boolkmark it aand return to read more of your useful
information. Thanks for thee post. I’ll certainly return.
Thhis is thee perfect blog for anybody who hopes to find out about this topic.
You definitely put a brand neww spin onn a topic which has been discussed for decades.Wondrful stuff,
juwt excellent!
Way cool! Some very valid points! I appreciate you penning this
post and the rest of the website is also really good.
Fabulous, what a web site it is! This web site provides useful data tto us, keep it up.
I havve found vwry interesting your article.It’s pretty
worth enough for me. In my view, if all website owners and
bloggers made good content as you did, the web will be a lot more useful than ever before.
Wonderful article! This is the kind of information that are supposed to be shared across the net.
Shame on Google for no longer positioning this post
higher! Come on over and seek advice from my site .
Thanks =)
Fine way of describing, and nice paragraph to obtain facts concerning my presentation focus, which i am going to convey in institution of higher education. games ps4 allenferguson games ps4
Thanks for sharing your thoughts on ps4 games. Regards
whoah this blog is great i like studying your posts.
Stay up the great work! You already know, many persons are
hunting round for this information, you could help them greatly.
Great article, just what I wanted to find.