Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Configure Code Replication

Learning Objectives

After completing this unit, you’ll be able to:
  • List the four code replication process types.
  • Describe how to transfer a new code version from a sandbox to a development instance.
  • List the code replication activation methods.
  • List three steps in a manual code replication process.

Introduction

Linda Rosenberg, Cloud Kicks' new administrator, learns that the site’s developer is ready to roll out some awesome storefront features. The developer checked their code into a version control system, then used a continuous integration/continuous deployment (CI/CD) tool to push a new code version to the staging instance. Now it’s Linda’s turn. With code replication, she can transfer the new code version from the staging instance to a development and then a production instance, and then activate it.

Linda Rosenberg, Administrator

Code replication, like data replication, has a source and a target. Data replication, however, deals with dependencies between data objects, which can make things complicated. Code replication is straightforward. When you replicate a code version, Salesforce B2C Commerce assigns the version on the target instance the same name as the source version on staging. If the name already exists, it appends a timestamp and index number to the name.

For example, the name of Cloud Kicks’ new code version is version-19b. A version with that name already exists on the target instance, so B2C Commerce names the new version version-19b_01202019-1.

Process Types

Like data replication, code replication is a two-step process.

  1. B2C Commerce transfers a code version from staging to the target instance.
  2. It activates the code on the target instance.

Linda can run both steps as a single replication process, or run them separately. Running them separately can help her identify any sources of failure if it occurs. All code replication processes run on the staging instance, even code activation and undo, which only affect the target instance.

There are four types of code replication processes.

  • Code Transfer: B2C Commerce transfers the selected code version on the source instance to the target instance, but it doesn’t activate it.
  • Code Transfer and Activation: B2C Commerce transfers the selected code version on the source instance to the target instance and then activates it.
  • Code Activation: This process is available only after a successful code transfer process. Activation makes the transferred code version the active version on the target instance. If the new code version is already active, nothing happens. If it doesn’t exist on the target instance, the replication fails.
  • Undo: This process is available only after a successful code transfer and activation or code activation replication process. It reverts the active code version on the target instance to the version that was active before the last code replication process. If the version you want to revert is no longer active, nothing happens. If it no longer exists on the target instance, or if the previously active code version no longer exists, the replication process fails.

Activation Methods

Linda can specify how she wants to run a replication process. Her choices are:

  • Manual: The process runs when she triggers it.
  • Automatic: She schedules a single day and time when the process runs.
  • Recurring: She schedules a recurring time when the process runs:
  • Job Step: The process is available to run as part of a job. We talk about jobs in the Salesforce B2C Commerce Scheduled Jobs module.

Create Process

Linda wants to get the new code out as soon as possible, and it’s after hours—a good time for this type of task. Here’s how she creates a code replication process that she can trigger manually.

  1. Open Business Manager.
  2. Select Administration > Replication > Code ReplicationBusiness Manager Code Replication
  3. Click New. (You must be on a staging instance to see this button.)
  4. B2C Commerce creates a process ID, or you can enter the text you want.
  5. Select the Development target instance.
  6. Enter an optional description. This can help you find it later.
  7. For activation type, select Manual.
  8. Select a notification email trigger and enter multiple target email addresses separated by commas. The email contains the start and end time of the process, target system, replication type, and replication tasks. If the process fails, the email notification includes an error code. Each process in a recurring series sends its own notification.
  9. Specify what happens for these events.
    • Process ends: B2C Commerce sends an email to the addresses when the process ends, whether it succeeds or fails. If it hangs, it doesn’t send an email.
    • Process fails: B2C Commerce sends an email to the addresses if the process fails. If the process succeeds or hangs, it doesn’t send an email.
  10. Click Next.
  11. For replication type, select Code Transfer and Activation.
  12. Click Next and review the process details. Once you create the process, you can’t change it.
  13. Click Start to create the process and immediately run it.

Linda and the developer test the new code on the development instance. When it looks good, she replicates the same code version from the staging instance to production. Now Cloud Kick’s shoppers can use the awesome new features!

Next Steps

In this unit, Linda learned that code replication is fairly straightforward and requires only a unique version number. After her developer uploaded code to the staging instance, she replicated it from staging to development and then production. She also learned about code replication process types and activation methods. She ran a manual code replication that pushed great new features out to the storefront.

Partagez vos commentaires sur Trailhead dans l'aide Salesforce.

Nous aimerions connaître votre expérience avec Trailhead. Vous pouvez désormais accéder au nouveau formulaire de commentaires à tout moment depuis le site d'aide Salesforce.

En savoir plus Continuer à partager vos commentaires