# What is a sub-flow and how to use it

**URL:** <https://community.synatic.com/t/what-is-a-sub-flow-and-how-to-use-it/156>\
**Category:** Flows\
**Tags:** helper-functions\
**Created:** [December 23, 2021, 7:34am UTC](https://community.synatic.com/t/what-is-a-sub-flow-and-how-to-use-it/156 "2021-12-23T07:34:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![navessa](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.synatic.com/navessa/32/58_2.png) [@navessa](https://community.synatic.com/u/navessa)\
**Post date:** [December 23, 2021, 7:34am UTC](https://community.synatic.com/t/what-is-a-sub-flow-and-how-to-use-it/156/1 "2021-12-23T07:34:17Z")

</div>

A sub-flow allows you to have more than one source in a flow. **Multiple sources** can be used to push data/ records into one or more destination/s.

Below is an example of a flow with a sub-flow. The Record Generator step is used as the primary source and Salesforce source step is used as the secondary source. The sub-flow pushes the records from both sources into a buffer as a destination.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/2711d707e4dbd3126714fb3ea0cd5501b171600f.png)

In the Record Generator step, I created my own field called “Number” and gave it a value as shown below.

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/296d05c23af5cdf7ed6a5bc4717e92bafcb0a248.png)

In the Calculator step, the Number field is being used as a parameter to pass the field with it’s value to the sub-flow as highlighted below. “NumberTest” is the created name for the parameter field.

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/29f01d4e6f325913f1f7010141a8f3f12af4df7b.png)

In the Salesforce source step, a connection to Salesforce was created and there are certain fields that were selected from the Account object as illustrated below.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/ac7254167764d4f0dbab2715d839ae867db2bdbe.png)

Click on the below icon in the sub-flow to choose the return value.

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/4eb80133c3d9fbf51b8598ed364fa848ccfd7f41.png)

The below page will appear and you can select a Type and Source and save. I chose “Object” as a Type since my sub-flow is pulling from Salesforce as a source and I selected “Record” to show the results as an output for the sub-flow. I created a field called “Mappings” in the Add To Record As field.

**NB:** If there is **no source** in the sub-flow, choose “ **Current** ” as the Return Type.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/2833ea80c1ffb9e65411b251ec9349d7b63efef9.png)

The output is highlighted in the below image. The Number field and value from the Record Generator is being passed as a parameter and the fields from Salesforce are in the Mappings field.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/bfa4c193f0b6f083563c710d9bc78e9d4c189816.png)

**Additional information:**

**Returns**

The options below let you define how you want the data to be returned from the Sub-flow.

**Return Type**

Select the option type you want the Sub-flow value to be returned as one of the following:

![](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/c39644d9c8e60a071d0c9b5808f3637258f5449c.png)

- **None** - No return. This is equivalent to `void` in traditional programming
- **Current** - The default of the sub-flow being called
- **Array** - Converts the output to an array
- **Object** - Converts the output to an object
- **String** - Converts the output to a string
- **Binary** - Converts the output to a binary representation

**Return Source**

Selects what _value types_ to return from the flow you are calling.

![](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/5aaad285db81304f15d369cfcb82aa695692eea0.png)

- **Auto** - Auto detects the appropriate output
- **Record** - Returns the current record processed by the sub flow.
- **Output** _-_ Returns the output of the Writer Step (if any) in the sub flow.
- **Result** - Returns the output of the Destination Step (if any) in the sub flow.

**Add to Record As**

Adds the return to the current record in the parent flow as the field specified.
