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 or updated products in Salesforce with inventory and assembly items 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.

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 product.

Trigger from Sales Cloud on new or updated product.

Fetch the associated price book.

Action step to get all price books that have the same price book ID as that associated with the triggering product in Sales Cloud.

Fetch the associated price book entry.

Action step to get all price book entries that have the same price book ID and product ID as those associated with the triggering product in Sales Cloud.

Iterate over each price book entry.

For Each block with the list of price book entries as the input list. Note the remaining steps of your flow are enclosed in this For Each block.

Fetch a corresponding inventory item, if any.

Action step to get all inventory items that have the same product ID as that of the triggering product in NetSuite.

Determine if the triggering product has a corresponding inventory item.

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

If a corresponding inventory item doesn’t exist

Within the If block:

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

If a corresponding inventory item exists

In the Else branch of the If/Else block, update the inventory item with relevant product details in NetSuite.

Fetch the corresponding inventory item.

Action step to get all inventory items that have the same product ID as that of the triggering product in NetSuite.

Create an associated assembly item.

Action step to create an assembly item that contains the inventory item in NetSuite. Ensure the assembly item uses the same subsidiary’s internal ID as that associated with its inventory item.

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 new or updated products in Salesforce with inventory and assembly items in NetSuite. 

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 Salesforce Products to NetSuite Inventory and Assembly Items 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 a product 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 Product.
  3. Look at the Sample Output section, which shows fields and associated sample values from a product in the NTO org. This confirms that 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 price books that have the same price book ID as that associated with the triggering product in Sales Cloud. 

  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 price books that have the same price book ID as that associated with the triggering product in Sales Cloud. 

  1. Click in the Action field and select Get records.
  2. In the Object Type field, enter Price Book.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select Price Book ID as the field, Equals as the operator, and the price book ID for your standard price book obtained in unit 1. In the example of this flow, it’s 01s1U000005mSpYQAU.

Create the third step for the flow to get all price book entries that have the same price book ID and product ID as those associated with the triggering product in Sales Cloud. 

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

Configure the third step to get all price book entries that have the same price book ID and product ID as those associated with the triggering product in Sales Cloud. 

  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 Pricebook2Id as the field and Equals as the operator, and then enter the price book ID for your standard price book obtained in unit 1. In the example of this flow, it’s 01s1U000005mSpYQAU.
  5. Click Add a condition.
  6. Select Product2Id as the field, Equals as the operator, and Product ID from step 1 of the flow.

Create and configure a For Each block to iterate over each price book entry fetched from the list of price book entries in step 3 of the flow. Note the remaining steps of your flow are enclosed in this For Each block.

  1. Click the plus icon to add a step.
  2. Scroll down and select For Each.
  3. In the Input list field, select List of Price Book Entry from step 3 of the flow.

Create the fourth step for the flow to get all inventory items that have the same product ID as that of the triggering product in NetSuite. 

  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 fourth step of the flow appears.

Configure the fourth step to get all inventory items that have the same product ID as that of the triggering product in NetSuite.

  1. Click in the Action field and select Get Records.
  2. In the Record Type field, enter INVENTORY_ITEM.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select Salesforce Product ID as the field, Is as the operator, and Product ID from step 1 of the flow.

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

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

Create the fifth step for the flow within the If branch of the If/Else block to create an inventory item with its associated product 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 fifth step within the If branch to create an inventory item with its associated product ID in NetSuite.

  1. Click in the Action field and select Create Record.
  2. In the Type of Record field, enter INVENTORY_ITEM.
  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 Record Ref List is automatically added. You map Record Ref List to the list of price book entries next.
    • Display Name
    • Item Id
    • Purchase Description
    • Record > Custom Field List > Salesforce Product ID
    • Record > Subsidiary List > Record Ref > InternalId
    • Record > Tax Schedule > InternalId
  5. Map the INVENTORY_ITEM fields to their corresponding fields captured in the preceding steps of the flow as follows.
    • Display Name = Product Name from step 1
    • Item Id = Product Code from step 1
    • Purchase Description = Product Description from step 1
    • Record > Custom Field List > Salesforce Product ID = Product ID from step 1
    • Record > Subsidiary List > Record Ref = List of Price Book Entry from step 3
    • Record > Subsidiary List > Record Ref > InternalId = 1. This represents the Honeycomb Mfg subsidiary.
    • Record > Tax Schedule > InternalId = 1. This represents the S1 tax schedule.

Create the sixth step for the flow within the If branch of the If/Else block to update the triggering product with its associated inventory item’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 sixth step within the If branch to update the triggering product with its associated inventory item’s internal ID 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. Use the search tool to select NetSuite Item ID and click Add.
  5. Map the Product fields to their corresponding fields captured in the preceding steps of the flow as follows.
    • Product ID = Product ID from step 1
    • NetSuite Item ID = InternalId from step 5

Create an Else branch within the If/Else block to update the inventory item that corresponds to the triggering product.

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

Create the seventh step within the Else branch of the If/Else block to update the inventory item with relevant product details in NetSuite.

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

Configure the seventh step to update the inventory item with relevant product details in NetSuite.

  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. Using the search field, locate and select the following fields, and then click Add.
    • Display Name
    • Purchase Description
  6. Map the INVENTORY_ITEM fields to their corresponding fields captured in the preceding steps of the flow as follows.
    • Record Id = NetSuite Item ID from step 1
    • Display Name = Product Name from step 1
    • Purchase Description = Product Description from step 1

Create the eighth step for the flow to get all inventory items that have the same product ID as that of the triggering product in NetSuite. Note this step is outside of the If/Else block but within the larger For Each block.

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

Configure the eighth step to get all inventory items that have the same product ID as that of the triggering product in NetSuite. You use this information to populate an assembly item next.

  1. Click in the Action field and select Get Records.
  2. In the Record Type field, enter INVENTORY_ITEM.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select Salesforce Product ID as the field, Is as the operator, and Product ID from step 1 of the flow.

Create the ninth step for the flow to create an assembly item containing its associated inventory item with relevant product and inventory item details 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 ninth step to create an assembly item containing its associated inventory item with relevant product and inventory item details in NetSuite. Ensure the assembly item uses the same subsidiary’s internal ID as that associated with its inventory item.

  1. Click in the Action field and select Create Record.
  2. In the Type of Record field, enter ASSEMBLY_ITEM.
  3. Click Add Fields.
  4. Using the search field, locate and select the following fields, and then click Add.
    As a result, three more fields are automatically added: Item Member List and two Pricing Lists. You map them to their associated fields next.
    • Description
    • Display Name
    • Item Id
    • Use Component Yield
    • Record > Member List > Item Member > Bom Quantity
    • Record > Member List > Item Member > Item > InternalId
    • Record > Pricing Matrix > Pricing > Currency > InternalID
    • Record > Pricing Matrix > Pricing > Price Level
      • InternalID
      • Name
    • Record > Pricing Matrix > Pricing > Price List
      • Quantity
      • Value
    • Record > Subsidiary List > Record Ref > InternalId
    • Record > Tax Schedule > InternalId
  5. Map the ASSEMBLY_ITEM fields to their corresponding fields captured in the preceding steps of the flow as follows.
    Note: For fields that must be mapped to multiple values, click in the field and then click Custom Expression. The Custom Expression Editor opens. You use this Custom Expression Editor to configure a field that has both dynamic field values from the preceding steps of a flow and static text that you enter.
    • Description = Product Description from step 1 assembly item (insert a space before assembly)
    • Display Name = Product Name from step 1 Last Modified Date from step 1 (insert a space before Last Modified Date)
    • Item Id = Product Code from step 1 Last Modified Date from step 1 (insert a space before Last Modified Date)
    • Use Component Yield = true. This is used to automatically calculate the BOM quantity for loss of raw materials during the manufacturing process.
    • Record > Member List > Item Member > Item Member List = List of INVENTORY_ITEM from step 8
    • Record > Member List > Item Member > Bom Quantity = 10
    • Record > Member List > Item Member > Item > InternalId = Record > InternalId from step 8
    • Record > Pricing Matrix > Pricing > Pricing List = List of Price Book Entry from step 3
    • Record > Pricing Matrix > Pricing > Currency > InternalID = 1. This represents the US dollar.
    • Record > Pricing Matrix > Pricing > Price Level:
      • InternalID = 1. This represents the List Price level in the USA dollar sublist.
      • Name = List Price. This is the name of the List Price level in the USA dollar sublist.
    • Record > Pricing Matrix > Pricing > Price List > Price > Price List = List of Price Book Entry from step 3
    • Record > Pricing Matrix > Pricing > Price List:
      • Quantity = 0. This represents the QTY 0 column in the USA dollar sublist.
      • Value = List Price from step 3
    • Record > Subsidiary List > Record Ref = List of Price Book Entry from step 3
    • Record > Subsidiary List > Record Ref > InternalId = 1. This represents the Honeycomb Mfg subsidiary, which is the same as that used to create the inventory item in step 5 of the flow.
    • Record > Tax Schedule > InternalId = 1. This represents the S1 tax schedule.
  6. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new or updated product in Salesforce as the trigger.Step 2 of flow to get all price books with condition price book ID equals price book ID of the standard price book.Step 3 of flow to get all price book entries with condition price book ID equals price book ID of the standard price book and product ID equals product ID in step 1.For Each block iterating over list of price book entries and step 4 of flow to get all inventory items with condition Salesforce product ID is product ID in step 1.If/Else block with If branch to evaluate whether list of inventory items is empty.Step 5 of flow to create a NetSuite inventory item with fields such as display name, item id, and purchase description.Rest of step 5 of flow with fields such as record ref list and tax schedule.Step 6 of flow within If branch to update product with fields such as product ID and NetSuite item ID. Also shown is the Else branch.Step 7 of flow within Else branch to update NetSuite inventory item with fields such as display name and purchase description.Outside of If/Else block but within For/Each block is step 8 of flow to get all inventory items with condition Salesforce product ID is product ID in step 1.Step 9 of flow within For Each block to create a NetSuite assembly item with fields such as description, display name, and item id.More of step 9 of flow with fields such as item member list, BOM quantity, and currency.More of step 9 of flow with fields such as price list, quantity, and value.Rest of step 9 of flow with tax schedule’s internal ID.

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