2

We can setup an associating account on a community.

I'd like to know How could we get the associated Account through Apex code?

Is there any field I could query from the SOQL or APEX class?

e.g:

SELECT ID, Name, SelfRegProfileId, SelfRegAccountId FROM Network WHERE ID= xxx

enter image description here

  • Do you want to define the account on this screen or you are looking a way on how will an account be identified when a User does a self registration? – Jayant Das Aug 10 '18 at 20:06
  • I'm saying I've already defined here. But on the backend code I need to find a way this field is setup or not. – Dummy Aug 10 '18 at 20:27
3

You need the NetworkSelfRegistration object here. From documentation:

Represents the account that self-registering community members are associated with by default. Self-registering users in a community are required to be associated with an account, which the administrator must specify while setting up self-registration for the community.

So your query will be as:

SELECT AccountId FROM NetworkSelfRegistration WHERE NetworkId = 'id of the community'
  • And for the corresponding profile. We need to query from SELECT ID, Name, SelfRegProfileId FROM Network ? Not sure why Salesforce separate this information into 2 diffrent tables LOL – Dummy Aug 10 '18 at 20:45
  • Everyday is a new day in Salesforce :). Glad that it worked out for you. – Jayant Das Aug 10 '18 at 20:46

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.