Skip to main content

Hi Everyone,

I have an Experience Cloud site where the users are using the Customer Community Plus license.

I have a requirement to create a new Customer Community Plus user from an LWC/Apex component. As part of the user creation process, I need to select the appropriate Customer Community Plus Profile.

To populate the Profile selection, I need to fetch the available Profiles from the org using Apex.

I tried the following SOQL:

List<Profile> profiles = [

SELECT Id, Name

FROM Profile

];

However, when this code executes in the context of a Customer Community Plus user, I receive the following error:

sObject type 'Profile' is not supported

I also understand that Experience Cloud users have restrictions on accessing certain standard objects.

My questions are:

  1. Is there any way to grant a Customer Community Plus user access to the Profile sObject through a Profile, Permission Set, or any other Salesforce configuration?
  2. If direct access to the Profile object is not supported for Customer Community Plus users, what is the recommended Salesforce approach for retrieving the appropriate Customer Community Plus Profile when creating another user?
  3. Is there any supported Apex/API approach to retrieve the available Customer Community Plus Profiles without directly querying the Profile object?

My requirement is specifically:

Existing Customer Community Plus user → LWC/Apex → Create a new Customer Community Plus user → Select the appropriate Customer Community Plus Profile

Any guidance or recommended approach would be greatly appreciated.

Thanks! 

 

#Salesforce Developer  #LWC  #Profiles  #Experience Cloud

3 件の回答
  1. 今日、15:52

    Hi Kavya, 

     

    This error almost always means the Profile Id isn't actually landing on the User record at insert time — a few common causes: 

     

    1. Field name typo. Make sure you're setting ProfileId on the User sObject, not Profile (Profile isn't a writable field on User — ProfileId is). Easy mistake if copy-pasting variable names. 

     

    2. Empty/null value from the picklist. Confirm the value coming from your LWC picklist (bound to Custom Metadata) is actually the 15/18-char Profile Id and not the label — double check the LWC is sending the value attribute, not the label, on selection. 

     

    3. Wrong API/method for the context. If you're doing a plain insert(newUser) from Apex running in the Community Plus user's session, the platform can silently reject or blank out certain fields (including ProfileId) depending on context — this is exactly the scenario Site.createExternalUser() is built to handle correctly. Double check you're actually calling Site.createExternalUser(newUser, accountId, password, options) and not a raw DML insert. 

     

    4. Debug it directly: right before the create call, add a debug log for newUser.ProfileId — if it prints null/blank there, the issue is upstream (LWC → Apex value binding), not the create call itself. 

     

    Reference:

    https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_site.htm#apex_System_Site_createExternalUser

     

     

    Check the debug log for ProfileId right before the create call first — that'll tell you immediately if it's a value-passing issue or a method issue.

0/9000