Skip to main content

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

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 that the NetSuite Customer entity contains a combination of simple and list fields whereas the Salesforce Account object contains only simple fields. 

Specifically, the NetSuite Customer entity contains the addressBookList field. This list field consists of 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 entity UI. 

The Salesforce Account object, however, 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.

To tackle this challenge of mapping a NetSuite list field to a group of Salesforce simple fields, use a For Each block in your flow to iterate over each address of a NetSuite customer. Then, use an action step to create a Salesforce account, mapping each field of the customer’s address to a corresponding field of the account’s address. 

Note

In your flow, use one billing address and one shipping address from each NetSuite customer to populate the corresponding Salesforce account’s billing and shipping addresses. Don’t use any additional addresses from NetSuite customers to populate Salesforce accounts.

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

Task Flow Components

Find any new customer in NetSuite.

Trigger from NetSuite on new customer.

Determine if a corresponding account exists in Sales Cloud.

Action step to get all accounts that have the same name as the customer’s company name.

If a corresponding account doesn’t exist

If/Else block to check if the list of accounts is empty, meaning the account doesn’t exist in Sales Cloud. 

Iterate over the customer’s addresses

Within the If/Else block, use a For Each block to iterate over the customer’s addressBookList field.

Determine if the address is the default billing address.

Within the For Each block, use a second If/Else block to check if the address is the default billing address, and then perform the following steps.

  • Action step to create a new account with the billing address and other customer details, including the customer’s internal ID, in Sales Cloud.
  • Action step to update the customer with its associated account ID in NetSuite.

Determine if the address is the default shipping address.

Within the second If/Else block, add a second If branch to check if the address is the default shipping address, and then use an action step to update the corresponding account with the shipping address in Sales Cloud.

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

Design a Flow

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

Note

The solution to this flow appears at the end of this section. If you have any issues with designing your flow, refer to the solution flow for guidance. 

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

Create a trigger for the flow using the NetSuite connection.

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

Configure the trigger to start the flow every time a new customer is created in NetSuite.

  1. Click in the Choose an event that starts this flow field and select New Record.
  2. In the Type of Record field, enter CUSTOMER.
  3. Click Save to save the flow.

Create the second step for the flow to get all accounts in Salesforce that match the triggering customer.

  1. Click the plus icon to add a step.
  2. Click Salesforce.
  3. 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.
  4. Name the connection NTO sandbox org.
  5. 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.
  6. Enter your NTO sandbox org’s username and password and click Log In to Sandbox.
  7. 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 accounts that match the customer.

  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 Company Name from step 1 of the flow.

Create and configure an If/Else block to evaluate whether the customer has a corresponding 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 customer doesn’t have a corresponding account in Sales Cloud.

Create and configure a For Each block to iterate over each address of the customer.

  1. Click the plus icon and then select For Each.
  2. In the Input list field, select Record > Addressbook List > Addressbook from step 1 of the flow.

Create and configure a second If/Else block within the For Each block to check if the customer’s address is the default billing address.

  1. Click the plus icon within the For Each block 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. Enter default, and then select Record > Addressbook List > Addressbook > Default Billing from step 1 of the flow as the field and Is true as the operator. If this condition is met, it means the address is the default billing address. So the next two steps in the second If/Else block (create Salesforce account and update NetSuite customer) are executed.

Create the third step for the flow within the second If/Else block to create a new account in Sales Cloud.

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

Configure the third step to create a new account, including the customer’s billing address and internal ID, in Sales Cloud.

  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 Select Optional Fields.
  4. Use the search tool to select Account Phone, Billing Street, Billing City, Billing State/Province, Billing Zip/Postal Code, Billing Country, Website, and NetSuite Customer ID.
    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 Apply.
  5. Click Apply.
  6. Map the Account fields in Sales Cloud to their corresponding Customer fields in NetSuite captured in step 1 of the flow as follows.
    • Account Name = Record > Company Name
    • Account Phone = Record > Phone
    • Billing Street = Record > Addressbook List > Addressbook > Addressbook Address > Addr1 
    • Billing City = Record > Addressbook List > Addressbook > Addressbook Address > City 
    • Billing State/Province = Record > Addressbook List > Addressbook > Addressbook Address > State 
    • Billing Country = Record > Addressbook List > Addressbook > Addressbook Address > Country
    • Website = Record > URL
    • NetSuite Customer ID = Record > InternalID

Create the fourth step for the flow within the second If/Else block to update the customer with its associated account ID.

  1. Click the plus icon to add a step to the second If/Else block.
  2. Click NetSuite and then click NTO NetSuite.

Configure the fourth step to update the customer with its associated account ID.

  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 Select Optional Fields.
  5. In the search field, enter salesforce, select Salesforce Account ID, and then click Apply.
  6. Map the Customer fields in NetSuite to the preceding steps of the flow as follows.
    • Record Id = Record > InternalId from step 1
    • Salesforce Account ID = Id from step 3

Create and configure a second If branch within the second If/Else block to check if the customer’s address is the default shipping address.

  1. Scroll down and click Add If within the second If/Else block. The All conditions must be met (AND) condition is selected by default.
  2. Enter default, and then select Record > Addressbook List > Addressbook > Default Shipping from step 1 of the flow as the field and Is true as the operator. If this condition is met, it means the address is the default shipping address. So the next step in the second If branch of the second If/Else block (update Salesforce account) is executed.

Create the fifth step for the flow within the second If branch of the second If/Else block to update the corresponding account in Sales Cloud.

  1. Click the plus icon to add a step to the second If branch of the second If/Else block.
  2. Click Salesforce and then click NTO sandbox org.

Configure the fifth step to update the corresponding account with the customer’s shipping address 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 Select Optional Fields.
  4. Enter shipping in the search tool, and then select Shipping Street, Shipping City, Shipping State/Province, Shipping Zip/Postal Code, and Shipping Country.
  5. Click Apply.
  6. Map the Account fields in Sales Cloud to the preceding steps of the flow as follows.
    • Account ID = ID from step 3
    • Shipping Street = Record > Addressbook List > Addressbook > Addressbook Address > Addr1 from step 1
    • Shipping City = Record > Addressbook List > Addressbook > Addressbook Address > City from step 1
    • Shipping State/Province = Record > Addressbook List > Addressbook > Addressbook Address > State from step 1
    • Shipping Country = Record > Addressbook List > Addressbook > Addressbook Address > Country from step 1
  7. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new customer in NetSuite as the trigger.Step 2 of flow to get all accounts with condition that the account name in NTO org must match the company name of the customer in NetSuite.First If/Else block of flow showing condition to determine if list of accounts is empty and For Each block within first If/Else block to loop over the customer’s Addressbook.Second If/Else block within For Each block with condition to check for default billing address and Step 3 of flow within second If/Else block to create a new account in the NTO org.Rest of step 3 of flow to create a new account in the NTO org with company name, phone, full billing address, website, and NetSuite internalID from the customer.Step 4 of flow within the second If/Else block to update the customer with its associated account ID.Second If branch in second If/Else block with condition to check for default shipping address and Step 5 of flow within second If branch to update a corresponding account in the NTO org.Rest of step 5 of flow to update a corresponding account in the NTO org with full shipping address from the customer.

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

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities