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

Design a Flow

Learning Objectives

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

  • Prepare to design a flow.
  • Design a flow to automatically sync new or updated accounts between two Salesforce orgs and Slack.

Prepare to Design a Flow

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 to 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 or updated GD account.

Trigger from the GD org on new or updated account.

Fetch a corresponding NTO account, if any.

Action step to get all accounts in NTO with the same account name as the name of the triggering GD account.

Determine if a corresponding account exists in NTO.

If/Else block evaluating if the list of accounts is empty, meaning the GD account doesn’t exist in NTO. 

If a corresponding account doesn’t exist: 

  • Create NTO account.
  • Update GD account.
  • Post message to channel.

In the If branch of the If/Else block:

  • Create an NTO account with relevant details, including the associated GD account ID.
  • Update the GD account with the NTO account ID.
  • Post a message to the account-automation channel.

If a corresponding account exists, check the update user isn’t the Composer user, and then

  • Update NTO account.
  • Update GD account.
  • Post message to channel.

In the second If branch of the If/Else block: 

  • Check the user performing the update isn’t the Composer user.
  • If so, use a For Each block to iterate over the list of NTO accounts.

Within the For Each block:

  • Update the NTO account with relevant details, including the associated GD account ID.
  • Update the GD account with the NTO account ID.
  • Post a message to the account-automation channel.

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.

Design a Flow

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

Note

The Trailhead Simulator isn’t a Trailhead Playground. It provides a simulated experience and does not store your progress. If you close and relaunch the simulation, it restarts. You can use the navigation controls to return to where you left off. For the best experience, view the Trailhead Simulator on a computer, not a mobile device. Also, note that the Trailhead Simulator is designed to show a focus box on the correct click area if you click the wrong area first. To continue, simply click the focus area.

As you learned in unit 1, to avoid the problem of infinite looping when running your flow, use the Composer user’s username and password to create a connection to the GD org when designing your flow.

Follow these steps to design a flow.

Launch MuleSoft Composer from the NTO org.

  1. Launch the Trailhead Simulator, and on the title screen, click Begin.
  2. Log in to your NTO org using your username and password.
  3. 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 to Slack 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 or updated in the GD org.

  1. Click in the Choose an event that starts this flow field and select New or updated record.
  2. Click in the Object Type field and select Account.
  3. Look at the Sample Output section, which shows the 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.
  4. 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 get all NTO accounts with the same account name as the triggering GD account.

  1. Click in the Action field and select Get records.
  2. In the Object Type field, enter Account.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select Account Name as the field, Equals as the operator, and Account Name from step 1 of the flow.

Create and configure an If/Else block to evaluate whether the triggering GD account has a corresponding NTO account.

  1. Click the plus icon to add a step.
  2. Scroll down and click If/Else Block. The All conditions must be met (AND) condition is selected by default.
  3. Select List of Account from step 2 of the flow as the field and Is empty as the operator. If this condition is met, it means the GD account doesn’t have a corresponding NTO account. So the next three steps in the If branch (create NTO account, update GD account, and post Slack message) are executed.

Create the third step for the flow within the If branch of the If/Else block using the existing NTO sandbox org connection.

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

Configure the third step within the If branch to create an NTO account with relevant details, including its associated GD account ID.

  1. Click in the Action field and select Create new record.
  2. In the Object Type field, enter 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.
    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 selecting fields, click Add.
    • Account Phone
    • Account Rating
    • Billing City
    • Billing Country
    • Billing State/Province
    • Billing Street
    • Billing Zip/Postal Code
    • GD Account ID
    • Upsell Opportunity
  5. Map the NTO Account fields to their corresponding GD Account fields captured in step 1 of the flow as follows.
    • Account Name = Account Name
    • Account Phone = Account Phone
    • Account Rating = Account Rating
    • 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
    • Upsell Opportunity = Upsell Opportunity

Create the fourth step for the flow within the If branch using the existing GD sandbox org connection.

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

Configure the fourth step within the If branch to update the triggering GD account with its associated NTO account ID.

  1. Click in the Action field and select Update record.
  2. In the Object Type field, enter Account. The Account ID is automatically selected because it’s a required field.
  3. Click Add Fields.
  4. Use the search tool to select NTO Account ID and click Add.
  5. 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 3

Create the fifth step for the flow within the If branch using an NTO Slack connection.

  1. Click the plus icon within the If branch to add a step.
  2. Click Slack.
  3. Click Add new Slack connection.
    Note: If this is your first Slack connection, this option doesn’t appear. Go to the next step.
  4. Name the connection NTO Slack and click Create.
  5. Select NTO from the Slack workspace picklist.
  6. Click Allow to grant MuleSoft Composer the permissions to view content and info about channels and conversations, view content and info about your workspace, and perform actions in channels and conversations in the NTO workspace. The MuleSoft Platform app is automatically added to the NTO Slack workspace, and the fifth step of the flow appears.

Configure the fifth step to notify the account-automation channel of new GD accounts.

  1. Click in the Action field and select Post message to channel.
  2. In the Channel Name field, click the search picklist, select Pick from List, and then select account-automation.
  3. Click in the Message field and then click Custom Expression. The Custom Expression Editor appears. You use this Custom Expression Editor to configure a message that has both dynamic field values from the preceding steps of a flow (also known as data pills) and static text that you enter.
  4. Configure the following message. Use the Data tab to select the relevant data pills. Note that \n inserts a new line and the data pills enclosed with asterisks (*) appear bold in Slack.
    New GD account: *Account Name* from step 1 \n Rating: *Account Rating* from step 1 \n Upsell potential: *Upsell Opportunity* from step 1
  5. Click Apply.

Create the second If branch within the If/Else block to update the NTO account that corresponds to the triggering GD account. In this If branch, you check if the user performing the update isn’t the Composer user, thus ensuring the infinite looping problem doesn’t occur at runtime. 

  1. From the bottom of the If/Else block, click Add If. The All conditions must be met (AND) condition is selected by default.
  2. Select Last Modified by Id from step 1 of the flow as the field, Does not equal as the operator, and enter the Salesforce ID of the Composer user found in unit 1. In this example, it’s 0055A000008sCOOQA2. If this condition is met, it means the user performing the update is an end user, not the Composer user. So the next three steps in the second If branch (update NTO account, update GD account, and post Slack message) are executed.

Create and configure a For Each block within the second If branch to iterate over each item in the list of NTO accounts in step 2 of the flow.

  1. Click the plus icon in the second If branch.
  2. Scroll down and select For Each.
  3. In the Input list field, select List of Account from step 2 of the flow.

Create the sixth step within the For Each block using the existing NTO sandbox org connection.

  1. Click the plus icon to add a step within the For Each block.
  2. Click Salesforce and then select NTO sandbox org.

Configure the sixth step to update the NTO account that corresponds to the triggering GD account.

  1. Click in the Action field and select Update record.
  2. In the Object Type field, enter Account. The Account ID 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.
    • Account Phone
    • Account Rating
    • Billing City
    • Billing Country
    • Billing State/Province
    • Billing Street
    • Billing Zip/Postal Code
    • GD Account ID
    • Upsell Opportunity
  5. Map the NTO Account fields to their corresponding Account fields captured in the preceding steps of the flow as follows.
    • Account ID = Account ID from step 2
    • Account Phone = Account Phone from step 1
    • Account Rating = Account Rating from step 1
    • Billing City = Billing City from step 1
    • Billing Country = Billing Country from step 1
    • Billing State/Province = Billing State/Province from step 1
    • Billing Street = Billing Street from step 1
    • Billing Zip/Postal Code = Billing Zip/Postal Code from step 1
    • GD Account ID = Account ID from step 1
    • Upsell Opportunity = Upsell Opportunity from step 1

Create the seventh step for the flow within the second If branch using the existing GD sandbox org connection.

  1. Click the plus icon to add a step within the second If branch.
  2. Click Salesforce and then click GD sandbox org.

Configure the seventh step within the second If branch to update the triggering GD account with its associated NTO account ID.

  1. Click in the Action field and select Update record.
  2. In the Object Type field, enter Account. The Account ID is automatically selected because it’s a required field.
  3. Click Add Fields.
  4. Use the search tool to select NTO Account ID and click Add.
  5. 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 = Account ID from step 2

Create the eighth step for the flow within the second If branch using the existing NTO Slack connection.

  1. Click the plus icon to add a step within the second If branch.
  2. Click Slack and then click NTO Slack.
    Note: Here, you’re simply reusing the existing NTO Slack connection.

Configure the eighth step within the second If branch to notify the account-automation channel of updated GD accounts.

  1. Click in the Action field and select Post message to channel.
  2. In the Channel Name field, click the search picklist, select Pick from List, and then select account-automation.
  3. Click in the Message field and then click Custom Expression.
  4. Configure the message as follows:
    Updated GD account: *Account Name* from step 1 \n Rating: *Account Rating* from step 1 \n Upsell potential: *Upsell Opportunity* from step 1
  5. Click Apply.
  6. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new or updated GD account as the trigger.Step 2 of flow to get all NTO accounts on condition account name must match GD account name in step 1 of flow.If/Else block with If branch showing condition list of accounts in step 2 of flow is empty.Step 3 of flow in If branch to create a new account with fields such as account name, phone, and rating.Rest of step 3 with fields such as billing street, billing city, GD account ID, and upsell opportunity.Step 4 of flow to update GD account with NTO account ID.Step 5 of flow to post a message to account-automation channel about new GD account.Second If branch on condition the updating user isn’t the Composer user with For Each block looping over list of accounts from step 2 of flow.Step 6 of flow in second If branch to update NTO account with fields such as account phone and rating.Rest of step 6 with fields such as billing street, billing city, GD account ID, and upsell opportunity.Step 7 of flow to update GD account with NTO account ID.Step 8 of flow to post a message to account-automation channel about updated GD account.

Good job! In the next unit, you learn how to test your flow to ensure it works as expected.

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"