Loading
Get Started with B2C Commerce
Sommario
Seleziona filtri

          Nessun risultato
          Nessun risultato
          Ecco alcuni suggerimenti per la ricerca

          Controlla l'ortografia delle parole chiave.
          Usa termini di ricerca più generici.
          Seleziona meno filtri per ampliare la tua ricerca.

          Cerca in tutta la Guida di Salesforce
          Configure a Login Flow at the Primary Salesforce Org

          Configure a Login Flow at the Primary Salesforce Org

          To synchronize a user's identity between B2C Commerce and the Salesforce org IdP, configure a login flow at the primary Salesforce org. When a user signs in to the Salesforce IdP org, this flow handles the synchronization.

          1. Sign in to the primary Salesforce org acting as the IdP.
          2. Create the Login Flow invocable action.
            1. At the top of the page, click Setup gear icon and select Setup.
            2. In the Quick Find box, enter and select Apex Classes.
            3. Click New.
            4. Copy this code and paste it into the Apex Class editor.
              /**
               * Invocable action for the login flow to synchronize the merchant's
               * identity between the Commerce Cloud and the Core Identity Provider.
               */
              public class CommerceIdentitySyncAction {
                  @InvocableMethod(
                      label='Sync Commerce Identity'
                      description='Establishes the mapping between the logged-in core user and the ECOM user.'
                      category='Identity'
                  )
                  public static List<ActionResult> execute() {
                      List<ActionResult> results = new List<ActionResult>();
                      ActionResult result = new ActionResult();
                      try {
                          // Invoke the system identity synchronization logic
                          Auth.CommerceIdentitySynchronizationAction.UserSynchronizationResult syncStatus =
                              Auth.CommerceIdentitySynchronizationAction.establishUserSynchronization();
                          if (syncStatus != null) {
                              result.isSuccess = syncStatus.isSuccess;
                              result.errorMessage = syncStatus.errorMessage;
                          }
                      } catch (Exception ex) {
                          // Catching any unexpected issues to prevent the Login Flow from breaking
                          result.isSuccess = false;
                          result.errorMessage = 'An unexpected error occurred during identity sync: ' + ex.getMessage();
                      }
                      results.add(result);
                      return results;
                  }
                  /**
                   * Captures the status of the synchronization for use in Flow decision elements.
                   */
                  public class ActionResult {
                      @InvocableVariable(label='Is Success' description='True if the identity mapping was created successfully.')
                      public Boolean isSuccess;
                      @InvocableVariable(label='Error Message' description='The reason the synchronization failed, if applicable.')
                      public String errorMessage;
                  }
              }
            5. Click Save.
          3. Create and assign the login flow in Salesforce IdP org.
            1. In the Quick Find box, find and select Flows.
            2. Click New, and then select Screen Flow.
            3. Between Screen Flow Start and End, click the + button, and then select Action.
            4. Search for the action Sync Commerce Identity.
            5. Select the action and provide a Label and API Name.
            6. Click Save.
            7. Click Activate, and then exit Flow Builder.
          4. In the Quick Find box, enter and select Login Flows.
          5. Click New, and enter the field values in the table.
            Field Value
            Type Flow
            Flow Select the flow that you created.
            User License Salesforce
            Profile Standard User
          6. Save your changes.
           
          Caricamento
          Salesforce Help | Article