Use Apex to Configure Self-Registration in Batches for High-Volume Sites

Your Experience Cloud site can handle twice as many self-registration requests at a time when they’re collected into batches and processed asynchronously rather than one at a time. The accounts and contacts created are owned and managed by the community administrator. After a batch is processed successfully, users receive an email with their login instructions. Batch processing self-registration requests improves performance and keeps your site moving during heavy traffic spikes. Minimal coding is required when you use the Apex controller that manages your self-registration flow.

Required Editions

Available in: Salesforce Classic and Lightning Experience
Available in: Enterprise, Developer, Performance, and Unlimited Editions
User Permissions Needed
To configure record and case creation in batches: Use Micro-Batching to Create Records
To publish an Experience Cloud site:
  • Be a member of the site AND Create and Set Up Experiences
  • OR
  • Be a member of the site AND an experience admin or publisher in that site
To edit Apex classes:
  • Author Apex
  • AND
  • Customize Application

External Identity and Customer Community license users or Customer Community Plus and Partner Community license users with account role optimization (ARO) enabled can use micro-batching for self-registration. Users can’t be created for existing accounts using self-registration.

Keep the following in mind when using Apex controllers to manage your self-registration flow:

  • For person account sites, leave the account and contact fields blank.
  • For business account sites, you must add an account. Contacts are optional, but they require a null value.
  • User sObjects are required for all sites.
  1. From Setup, in the Quick Find box, enter Apex Classes, and then select Apex Classes.
  2. Use this function for the Apex controller that manages your self-registration flow.
    
                String uuid = Network.createExternalUserAsync(user, contact, account);
              

    Contact is a (not yet saved) sObject.

    new Contact(
      		 FirstName = firstName,
      		 LastName = lastName,
        	Level__c = 'Primary');
    

    Account is an sObject.

    new Account(
      name = 'Account for '+ LastName,
      description = 'account description',
      active__c = 'Yes' );