Skip to main content

Design and Test a Flow

Learning Objectives

After completing this unit, you’ll be able to:

  • Design a flow to automatically sync new accounts between two Salesforce orgs.
  • Test your flow to ensure it syncs new accounts between two Salesforce orgs as expected.

Recall from MuleSoft Composer Basics that a flow is a sequence of steps that you assemble and configure to integrate systems and data. Before designing a flow, you should sketch out the steps of the flow using a flowchart. You can do this using paper and pencil so you can get a good idea of what your flow will look like.

Here’s an example flowchart showing all the steps of an integration flow for the NTO use case described in the previous unit. 

Flowchart for the integration flow for NTO use case.

Here’s a detailed description of the tasks and their associated flow components to create a flow for this NTO use case.

Task Flow Components

Find any new GD account.

Trigger from the GD org on new account.

Create an NTO account.

Action step to create an NTO account with relevant details, including the associated GD account ID.

Update the GD account.

Update the GD account with the NTO account ID. 

By default, MuleSoft Composer validates your work and provides contextual in-app help every step of the way. For example, when you add a connection to a system, MuleSoft Composer tests the connection to make sure it works before you can proceed to the next step. Also, to simplify building your flows, MuleSoft Composer prompts you to complete required fields within each step.

As a best practice, when building a flow, add a few steps and test iteratively until you complete the flow. 

Note

If you have a large integration task, it’s recommended that you break up the task into manageable, bite-sized chunks, and then create a flow for each chunk. This enables you to more easily and quickly build, test, and run your flows to accomplish the task.

Take a look at this video demonstration showing how to connect two different Salesforce orgs together using MuleSoft Composer.

Design a Flow

Now you’re ready to design an integration flow that automatically syncs new accounts between two Salesforce orgs. 

Follow these steps to design a flow.

Launch MuleSoft Composer from the NTO org.

  1. Log in to your NTO org using your username and password.
  2. From the App Launcher, enter Composer and select MuleSoft Composer.

Create a new flow.

  1. Click Create New Flow.
  2. Click the pencil icon next to the default flow name.
  3. Name the flow Sync Accounts - GD Org to NTO Org and click Save.

Create a trigger for the flow using a GD sandbox org connection.

  1. Click Salesforce.
  2. Click Add new Salesforce connection to create a connection to the GD sandbox org.
    Note: If this is your first Salesforce connection, this option doesn’t appear. Go to the next step.
  3. Name the connection GD sandbox org.
  4. Select the checkbox This is a sandbox organization and click Create.
    Note: If you use a developer org, skip selecting this checkbox and click Create.
  5. Enter your GD sandbox org’s username and password and click Log In to Sandbox.
  6. Click Allow to grant MuleSoft Composer the permissions to access the identity URL service, manage user data via APIs, and perform requests at any time. MuleSoft Composer automatically tests the connection. If no error message appears, you have a successful connection, and the first step (trigger) of the flow appears.

Configure the trigger to start the flow every time an account is created in the GD org.

  1. Click in the Choose an event that starts this flow field and select New record.
  2. Click in the Object Type field and select Account.
  3. Click Select Fields.
  4. Using the search field, locate and select the following fields, and then click Add. You use these fields to perform integration tasks in later steps of the flow.
    Tip: Enter a keyword for a field you want to search and then select the relevant field that appears. Clear the keyword and repeat the process for the next field. When done with selecting all fields, click Add.
    • Account ID
    • Account Name
    • Billing City
    • Billing Country
    • Billing State/Province
    • Billing Street
    • Billing Zip/Postal Code
    • NTO Account ID
  5. Look at the Sample Output section, which shows the selected fields and associated sample values from an account in the GD org. This confirms you’re connected to the correct org and lets you know the structure of the data that’s available in later steps of your flow.
    Step 1 of flow with trigger event and object type fields and Select Fields button.
  6. Click Save to save the flow.

Create the second step for the flow using an NTO sandbox org connection.

  1. Click the plus icon to add a step.
  2. Click Salesforce and then click Add new Salesforce connection.
  3. Name the connection NTO sandbox org.
    Note: Even though you’re logged in to your NTO org, you still need to create a connection to it to perform integration tasks.
  4. Select the checkbox This is a sandbox organization and click Create.
  5. Enter your NTO sandbox org’s username and password and click Log In to Sandbox.
  6. Click Allow to grant MuleSoft Composer the permissions to access the identity URL service, manage user data via APIs, and perform requests at any time. MuleSoft Composer automatically tests the connection. If no error message appears, you have a successful connection, and the second step of the flow appears.

Configure the second step to create an account in the NTO org with relevant details, including its associated GD account ID.

  1. Click in the Action field and select Create new record.
  2. Click in the Object Type field and select Account. The Account Name is automatically selected because it’s a required field.
  3. Click Add Fields.
  4. Using the search field, locate and select the following fields, and then click Add. You use these fields to capture the GD data retrieved in step 1 of the flow.
    • Billing City
    • Billing Country
    • Billing State/Province
    • Billing Street
    • Billing Zip/Postal Code
    • GD Account ID
  5. Click in each field and map the NTO Account fields to their corresponding GD Account fields captured in step 1 of the flow as follows.
    • Account Name = Account Name
    • Billing City = Billing City
    • Billing Country = Billing Country
    • Billing State/Province  = Billing State/Province
    • Billing Street = Billing Street
    • Billing Zip/Postal Code = Billing Zip/Postal Code
    • GD Account ID = Account ID

Create the third step for the flow using the existing GD sandbox org connection.

  1. Click the plus icon to add a step.
  2. Click Salesforce and then select GD sandbox org.
    Note: Here, you’re simply reusing the existing GD sandbox org connection.

Configure the third step to update the triggering GD account with its associated NTO account ID. 

  1. In the Action field, select Update record.
  2. In the Object Type field, select Account. The Account ID is automatically selected because it’s a required field.
  3. Click Add Fields, select NTO Account ID, and then click Add.
  4. Map the GD Account fields to their corresponding Account fields captured in the preceding steps of the flow as follows.
    • Account ID = Account ID from step 1
    • NTO Account ID = Id from step 2
  5. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new GD account as the trigger.Step 2 of flow to create an account with fields such as account name, billing city, country, and state.Rest of step 2 with fields such as billing street, zip, and GD account ID.Step 3 of flow to update GD account with NTO account ID.

Next, you learn how to test your flow. 

Test a Flow

After you’ve designed your flow, you must test it from end to end to ensure it syncs data as expected. 

As a best practice, test your flow using your test systems and data. After you’re done with testing, run the flow using your production systems and data. For Salesforce, this means using a sandbox org to test your flow and a production org to run your flow.

Also, as a best practice, test every possible path of your flow. For example, if your flow has an If branch and an Else branch in an If/Else block, ensure to test both branches.

In general, you have up to 10 minutes to complete a test. When the test completes or 10 minutes have passed, the test stops. As a best practice, you should get all required applications and data ready for the test before starting it.  

In this use case, when an account is created in the GD org, it triggers the flow. So be ready to create a test account in the GD org. 

Next, prepare to verify the following.

  • An account is created in the NTO org containing relevant details, including its associated GD account ID.
  • The GD account is updated with its associated NTO account ID.

Follow these steps to test a flow.

  1. In the Sync Accounts - GD Org to NTO Org flow, click Test. The flow goes into a read-only mode.
    Note: While the test is running, if for some reason you want to stop it, click Stop Test
  2. Log in to the GD sandbox org’s Sales Cloud and navigate to the Accounts tab page.
  3. Click New, create an account with the following values, and then click Save.
    • Account Name: ACME
    • Billing Street: 495 Park Avenue
    • Billing City: New York
    • Billing State/Province: New York
    • Billing Zip/Postal Code: 10022
    • Billing Country: United States
  4. Go back to your flow and wait for the test to complete. If all three steps of the flow show a green check mark, this indicates the flow ran successfully. Take a look at the Test Output section and see the record values you entered for the test.
    Tested flow showing a green check mark on step 1.Tested flow showing a green check mark on step 2.Tested flow showing the rest of step 2.Tested flow showing a green check mark on step 3.
  5. Log in to the NTO org’s Sales Cloud, navigate to the Accounts tab, and view all accounts. Verify an NTO ACME account matching the GD ACME account has been created. The account should contain all relevant details, including a GD account ID. In this example, it’s 0016e00002zgVOLAA2.
    NTO ACME account showing GD account ID and billing address.
  6. Return to the GD org’s Sales Cloud, verify the GD ACME account has been updated with the NTO account ID. In this example, it’s 0011U000026YA7FQAW.
    GD ACME account showing NTO account ID.
  7. Repeat steps 1 through 6 to test another account of your choice. Your flow should work as expected.

Nice job! In the next unit, you learn how to activate, monitor, and troubleshoot your flow in the production environment.

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"