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 in Salesforce with customers in NetSuite.

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 map the tasks your flow must perform to their corresponding steps in the form of flow components. You can do this using paper and pencil so you can get a good idea of what your flow will look like.

The main challenge with designing this flow is mapping data from the Salesforce Account object, which contains only simple fields, to the NetSuite Customer entity, which contains a combination of simple and list fields. 

Specifically, the Salesforce Account object handles multiple addresses for each account using two logical groups of simple fields. For billing address, the fields are billing street, billing city, billing state/province, billing zip/postal code, and billing country. For shipping address, the fields are shipping street, shipping city, shipping state/province, shipping zip/postal code, and shipping country. 

The NetSuite Customer entity, however, contains the addressBookList field. This field consists of simple fields such as street, city, state, zip, and country. This lets you enter multiple addresses for each customer. These fields are all mapped to the Address tab in the Customer UI. For simplicity in your flow, you populate just the customer’s billing address by setting the Default Billing field to true.

To tackle this challenge of mapping the Salesforce address fields to the NetSuite addressBookList field, you need to turn the Salesforce address fields into a list. To do this, you use an action step to get all accounts that have the same account ID as that of the triggering account, thus turning the result into a list. Then, you use this list to map the account’s address fields to their corresponding fields in the customer’s addressBookList.

Here’s an example of such mappings for the NTO use case described in the previous unit. 

Task Flow Components

Find any new or updated account.

Trigger from Sales Cloud on new or updated account.

Turn the triggering account’s address fields into a list.

Action step to get all accounts that have the same account ID as that of the triggering account, thus turning the result into a list.

Fetch a corresponding customer, if any.

Action step to get all customers in NetSuite that have the same company name as the name of the triggering account.

Determine if a corresponding customer exists in NetSuite.

If/Else block evaluating if the list of customers is empty, meaning the customer doesn’t exist in NetSuite. 

If a corresponding customer doesn’t exist

Within the If block:

  • Create a new customer with relevant account details, mapping the account’s address fields (in the form of a list) to their corresponding fields in the customer’s addressBookList in NetSuite. In this step, set the Default Billing field to true to populate only the billing address.
  • Update the account with the customer’s internal ID in Sales Cloud.

If a corresponding customer exists

In the Else branch of the If/Else block, use a For Each block to iterate over the list of customers fetched from NetSuite that have the same company name as the name of the triggering account.

Within the For Each block:

  • Update the customer, mapping the account’s address fields (in the form of a list) to their corresponding fields in the customer’s addressBookList.

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 Salesforce to NetSuite to Slack using MuleSoft Composer.

Design a Flow

Now, you’re ready to design an integration flow that syncs new or updated accounts in Salesforce with customers in NetSuite. 

Note

The Trailhead Simulator is not 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.

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 Salesforce Accounts to NetSuite Customers and click Save.

Create a trigger for the flow using the NTO org.

  1. Click Salesforce.
  2. Click Add new Salesforce connection to create a connection to the NTO sandbox org.
    Note: If this is your first Salesforce connection, this option doesn’t appear. Go to the next step.
  3. Name the connection NTO 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 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 first step (trigger) of the flow appears.

Configure the trigger to start the flow every time an account is created or updated in the NTO org.

  1. Click in the Choose an event that starts this flow field and select New or updated record.
  2. In the Object Type field, enter Account.
  3. Look at the Sample Output section, which shows fields and associated sample values from an account in the NTO org. This confirms you’re connected to the correct org and lets you know the structure of the data that is 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 to get all accounts in Sales Cloud that have the same account ID as that of the triggering account. 

  1. Click the plus icon to add a step.
  2. Click Salesforce and then click NTO sandbox org.

Configure the second step to get all accounts that have the same account ID as that of the triggering account. This turns the result into a list of accounts and enables you to map the account’s fields (in the form of a list) to their corresponding fields in the customer’s addressBookList in later steps of the flow.

  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 ID as the field, Equals as the operator, and Account ID from step 1 of the flow.

Create the third step for the flow to get all customers in NetSuite that have the same company name as the name of the triggering account. 

  1. Click the plus icon to add a step.
  2. Click NetSuite.
  3. Click Add new NetSuite connection.
    Note: If this is your first NetSuite connection, this option doesn’t appear. Go to the next step.
  4. Using the text file that contains the NetSuite connection parameter values, enter the required values with NTO NetSuite as the connection display name, and then click Create. MuleSoft Composer automatically tests the connection. If no error message appears, you have a successful connection, and the third step of the flow appears.

Configure the third step to get all customers that have the same company name as the name of the triggering account.

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

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

  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 CUSTOMER from step 3 of the flow as the field and Is empty as the operator. If this condition is met, it means the account doesn’t have a corresponding customer. So the next two steps in the If branch (create NetSuite customer and update Salesforce account) are executed.

Create the fourth step for the flow within the If branch of the If/Else block to create a customer with its associated account ID in NetSuite.

  1. Click the plus icon to add a step to the If branch.
  2. Click NetSuite and then click NTO NetSuite.

Configure the fourth step within the If branch to create a customer with its associated account ID in NetSuite.

  1. Click in the Action field and select Create Record.
  2. In the Type of Record field, enter CUSTOMER.
  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 with selecting all fields, click Add.

    As a result, another field called Addressbook List is automatically added. You map Addressbook List to the Salesforce list of accounts next.
    • Comments
    • Company Name
    • Phone
    • Url
    • Record > Addressbook List > Addressbook > Default Billing
    • Record > Addressbook List > Addressbook > Addressbook Address
      • Addr 1
      • City
      • Country
      • State
      • Zip
    • Record > Custom Field List > Salesforce Account ID
    • Record > Custom Form > InternalId
    • Record > Subsidiary > InternalId
  5. Map the Customer fields to their corresponding fields captured in the preceding steps of the flow as follows. Note that you map the account’s billing address to the customer’s billing address by using the list of accounts created in step 2 of the flow and setting the Default Billing property to true.
    • Comments = Account Description from step 1
    • Company Name = Account Name from step 1
    • Phone = Account Phone from step 1
    • Url = Website from step 1
    • Record > Addressbook List > Addressbook > Addressbook List = List of Account from step 2
    • Record > Addressbook List > Addressbook > Default Billing = true
    • Record > Addressbook List > Addressbook > Addressbook Address
      • Addr 1 = Billing Street from step 2
      • City = Billing City from step 2
      • Country = Billing Country from step 2
      • State = Billing State/Province from step 2
      • Zip = Billing Zip/Postal Code from step 2
    • Record > Custom Field List > Salesforce Account ID = Account ID from step 1
    • Record > Custom Form > InternalId = -2. Recall that this is the internal ID of the Standard Customer Form found in the previous unit.
    • Record > Subsidiary > InternalId = 1. Recall that this is the internal ID of the first primary subsidiary value found in the previous unit.

Create the fifth step for the flow within the If branch of the If/Else block to update the triggering account with its associated customer’s internal ID in Sales Cloud.

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

Configure the fifth step within the If branch to update the triggering account with its associated customer’s internal ID in Sales Cloud.

  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 NetSuite Customer ID and click Add.
  5. Map the Account fields to their corresponding fields captured in the preceding steps of the flow as follows.
    • Account ID = Account ID from step 1
    • NetSuite Customer ID = InternalId from step 4

Create an Else branch within the If/Else block to update the customer that corresponds to the triggering account.

  1. From the bottom of the If/Else block, click Add Else.

Create and configure a For Each block within the Else branch to iterate over each customer fetched from the list of customers in step 3 of the flow.

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

Create the sixth step within the For Each block to update the customer that corresponds to the triggering account.

  1. Click the plus icon to add a step within the For Each block.
  2. Click NetSuite and then click NTO NetSuite.

Configure the sixth step to update the customer that corresponds to the triggering account.

  1. Click in the Action field and select Update Record.
  2. In the Type of Record field, enter CUSTOMER.
  3. In the ID Type field, select INTERNAL. The Record Id is automatically selected because it’s a required field.
  4. Click Add Fields.
  5. Using the search field, locate and select the following fields, and then click Add. Another field called Addressbook List is automatically added. This is the NetSuite addressBookList field that you map to the Salesforce list of accounts.
    • Comments
    • Phone
    • Url
    • Record > Addressbook List > Addressbook > Default Billing
    • Record > Addressbook List > Addressbook > Addressbook Address
      • Addr 1
      • City
      • Country
      • State
      • Zip
    • Record > Custom Form > InternalId
    • Record > Subsidiary > InternalId
  6. Map the Customer fields to their corresponding fields captured in the preceding steps of the flow as follows. Note that you map the account’s billing address to the customer’s billing address by using the list of accounts created in step 2 of the flow and setting the Default Billing property to true.
    • Record Id = Record > InternalId from step 3
    • Comments = Account Description from step 1
    • Phone = Account Phone from step 1
    • Url = Website from step 1
    • Record > Addressbook List > Addressbook > Addressbook List = List of Account from step 2
    • Record > Addressbook List > Addressbook > Default Billing = true
    • Record > Addressbook List > Addressbook > Addressbook Address
      • Addr 1 = Billing Street from step 2
      • City = Billing City from step 2
      • Country = Billing Country from step 2
      • State = Billing State/Province from step 2
      • Zip = Billing Zip/Postal Code from step 2
    • Record > Custom Form > InternalId = -2. Recall that this is the internal ID of the Standard Customer Form found in the previous unit.
    • Record > Subsidiary > InternalId = 1. Recall that this is the internal ID of the first primary subsidiary value found in the previous unit.
  7. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new or updated account in Salesforce as the trigger.Step 2 of flow to get all accounts with condition that account ID in NTO org must match account ID of the account in step 1 of flow.Step 3 of flow to get all customers with condition that company name must contain account name in step 1 of flow.If/Else block with If branch showing condition that list of customers is empty.Step 4 of flow within If branch to create a new customer with fields such as company name, phone, and url.More of step 4 of flow to create a new customer with fields such as addressbook list, default billing, address, city, state, zip, and country.Rest of step 4 of flow to create a new customer with fields such as salesforce account ID, custom form internal ID, and subsidiary internal ID.Step 5 of flow to update account with NetSuite customer’s internal ID.Else branch with For Each block looping over list of NetSuite customers.Step 6 of flow within For Each block to update the customer with fields such as comments, phone, and url.More of step 6 of flow to update the customer with fields such as addressbook list, default billing, address, city, state, zip, and country.Rest of step 6 of flow to update the customer with fields such as custom form internal ID and subsidiary internal ID.

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

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios