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 updated inventory items in NetSuite with products and associated price book entries 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.

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

Task Flow Components

Find any updated inventory item in NetSuite.

Trigger from NetSuite on updated inventory item.

Fetch a corresponding product, if any.

Action step to get all products in Sales Cloud whose NetSuite item ID is the same as the inventory item’s internal ID.

Determine if a corresponding product exists in Sales Cloud.

If/Else block evaluating if the list of products is empty, meaning the product doesn’t exist in Sales Cloud. 

If a corresponding product doesn’t exist

Within the If block:

  • Create a product with relevant inventory item details, including the inventory item’s internal ID, in Sales Cloud.
  • Update the inventory item with its associated product ID in NetSuite.
  • Create a price book entry for the product in Sales Cloud.

If a corresponding product exists

In the Else branch of the If/Else block:

  • Update the product with relevant inventory item details in Sales Cloud.
  • Get all the price book entries associated with the product.
  • Iterate over the list of price book entries using a For Each block.
  • Within the For Each block, update the associated price book entry for the product 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.

Design a Flow

Now, you’re ready to design an integration flow that syncs updated inventory items in NetSuite with products and associated price book entries 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 NetSuite Inventory Items to Salesforce Products and Price Book Entries 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 an inventory item is updated in NetSuite.

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

Create the second step for the flow to get all products in Salesforce that match the triggering inventory item.

  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 products that match the inventory item.

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

Create and configure an If/Else block to evaluate whether the inventory item has a corresponding product.

  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 Product from step 2 of the flow as the field and Is empty as the operator. If this condition is met, it means the inventory item doesn’t have a corresponding product in Sales Cloud. So the next three steps in the If branch (create Salesforce product, update NetSuite inventory item, and create Salesforce price book entry) are executed.

Create the third step for the flow within the If branch of the If/Else block to create a product 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 third step to create a product, including the inventory item’s internal ID, in Sales Cloud.

  1. Click in the Action field and select Create new record.
  2. In the Object Type field, enter Product. The Product 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 with selecting all fields, click Add.
    • Active
    • NetSuite Item ID
    • Product Code
    • Product Description
  5. Map the Product fields to their corresponding Inventory Item fields captured in step 1 of the flow as follows.
    • Product Name = Record > Display Name
    • Active = true
    • NetSuite Item ID = Record > InternalID
    • Product Code = Record > Item ID
    • Product Description = Record > Purchase Description

Create the fourth step for the flow within the If branch to update the inventory item with its associated product ID.

  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 to update the inventory item with its associated product ID.

  1. Click in the Action field and select Update Record.
  2. In the Type of Record field, enter INVENTORY_ITEM.
  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. In the search field, enter salesforce, select Salesforce Product ID, and then click Add.
  6. Map the Inventory Item fields to the preceding steps of the flow as follows.
    • Record Id = Record > InternalId from step 1
    • Salesforce Product ID = Id from step 3

Create the fifth step for the flow within the If branch to create a price book entry for the product 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 to create a price book entry for the product in Sales Cloud.

  1. Click in the Action field and select Create new record.
  2. In the Object Type field, enter Price Book Entry. The List Price, Pricebook2Id, and Product2Id are automatically selected because they’re required fields.
  3. Click Add Fields.
  4. Use the search tool to select Active and click Add.
  5. Map the Price Book Entry fields to the preceding steps of the flow as follows.
    • List Price = Record > Cost from step 1
    • Pricebook2Id = 01s1U000005mSpYQAU. This is the value of the standard price book obtained in unit 1.
    • Product2Id = Id from step 3
    • Active = true

Create an Else branch within the If/Else block to update the existing product that corresponds to the inventory item and update the associated price book entry for the product.

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

Create the sixth step for the flow within the Else branch to update the existing product with its associated inventory item details in Sales Cloud.

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

Configure the sixth step to update the existing product with its associated inventory item details in Sales Cloud.

  1. Click in the Action field and select Update record.
  2. In the Object Type field, enter Product. The Product ID is automatically selected because it’s a required field.
  3. Click Add Fields.
  4. Select Active, Product Description, and Product Name, and then click Add.
  5. Map the Product fields to their corresponding Inventory Item fields captured in step 1 of the flow as follows.
    • Product ID = Record > Custom Field List > Salesforce Product ID
    • Active = true
    • Product Description = Record > Purchase Description
    • Product Name = Record > Display Name

Create the seventh step for the flow to get all price book entries in Sales Cloud that have the same product ID and price book ID as those of the existing product. 

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

Configure the seventh step to get all price book entries with associated product ID and price book ID. This turns the result into a list of price book entries, enabling you to iterate over it and update the associated price book entry for the existing product in the next step of the flow.

  1. Click in the Action field and select Get records.
  2. In the Object Type field, enter Price Book Entry.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select Product2Id as the field, Equals as the operator, and ID from step 6 of the flow.
  5. Select Pricebook2Id as the field, Equals as the operator, and enter 01s1U000005mSpYQAU. This is the value of the standard price book obtained in unit 1.

Create and configure a For Each block within the Else branch to iterate over the list of price book entries fetched from step 7 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 Price Book Entry from step 7 of the flow.

Create the eighth step for the flow within the For Each block to update the associated price book entry for the existing product in Sales Cloud.

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

Configure the eighth step within the For Each block to update the associated price book entry for the existing product in Sales Cloud.

  1. Click in the Action field and select Create or update record.
  2. In the Object Type field, enter Price Book Entry. The External ID Field to Match field automatically appears because it’s a required field.
  3. In the External ID Field to Match field, select Price Book Entry ID. The Price Book Entry ID is automatically selected because it’s a required field.
  4. Click Add Fields.
  5. Select Active and List Price, and click Add.
  6. Map the Price Book Entry fields to the preceding steps of the flow as follows.
    • Price Book Entry ID = Price Book Entry ID from step 7
    • Active = true
    • List Price = Record > Cost from step 1
  7. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing an updated inventory item in NetSuite as the trigger.Step 2 of flow to get all products with the condition that their NetSuite item IDs must equal the inventory item’s internal ID from step 1.If branch of If/Else block in flow showing condition to determine if list of products from step 2 is empty.Step 3 of flow in If branch to create a product with inventory item details such as internal ID, item ID, and purchase description from step 1.Step 4 of flow in If branch to update the inventory item with product ID from step 3.Step 5 of flow in If branch to create a new price book entry with cost from step 1.Else branch of If/Else block and step 6 of flow within Else branch to update the product with purchase description and display name from step 1.Step 7 of flow in Else branch to get all price book entries with product ID from step 6 and standard price book ID.For Each block in Else branch iterating over list of price book entries from step 7 of flow.Step 8 of flow in For Each block to update a price book entry with cost from step 1.

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

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback