# Sub Flow

Use the **Sub Flow** node to invoke another **Microflow** from within a main Microflow.\
Sub Flow enables developers to **break complex integration logic into smaller, reusable flows**, simplifying both design and maintenance.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FNYd1VfJZM1JFmymsm1tq%2Fimage.png?alt=media&#x26;token=5e002685-56de-4d30-b08d-bffed635fba2" alt=""><figcaption></figcaption></figure>

***

### Purpose

The **Sub Flow** node is used to:

* Call another Microflow from a parent Microflow
* Encapsulate a **stand‑alone section of logic** into a separate flow
* Improve readability of the main integration flow
* Promote **reusability and modular design**

If a portion of the main flow performs a specific, reusable task (for example, validation, transformation, or external lookup), it is a recommended practice to implement that logic as a separate Microflow and invoke it using a Sub Flow node.

***

### Benefits of Using Sub Flow

Using Sub Flow helps to:

* Avoid duplication of logic across multiple flows
* Apply the **single responsibility principle**
* Maintain smaller, easier‑to‑understand Microflows
* Simplify testing and troubleshooting
* Enable reuse of integration logic across multiple scenarios

Sub Flow is a key enabler for **clean and scalable integration design**.

***

### Sub Flow Node Configuration

The **Sub Flow Node Configuration Panel** contains **three tabs**, each responsible for a different aspect of configuration.

***

#### General Tab

The **General** tab contains basic node information, including:

* Title
* Task ID (system‑generated)
* Description

These properties help document and identify the Sub Flow within the parent Microflow.

***

#### Business Object Tab

The **Business Object** tab is used to configure:

* Input Business Objects passed to the Sub Flow
* Output Business Objects returned from the Sub Flow

This ensures a clear and well‑defined data contract between the parent flow and the sub flow.

***

#### Sub Flow Tab

The **Sub Flow** tab is used to select and manage the referenced Microflow.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2Fx2Llp7IiNxRrlHuyZaIt%2Fimage.png?alt=media&#x26;token=3859bf88-b949-4e62-8b86-e585bf3d8b2c" alt=""><figcaption></figcaption></figure>

| Property  | Mandatory | Description                                      |
| --------- | --------- | ------------------------------------------------ |
| Flow Name | Yes       | Select the Microflow to be invoked as a Sub Flow |

***

### Sub Flow Actions

Within the **Sub Flow** tab, the following actions are available:

* **Open Sub Flow**\
  Opens the selected sub Microflow for viewing or editing.
* **Open Mapping Parameter**\
  Opens the **Mapping Parameter screen**, where users can:
  * Map input parameters from the parent Microflow to the Sub Flow
  * Map output parameters from the Sub Flow back to the parent Microflow

This mapping mechanism ensures seamless data transfer between flows.

***

### Best Practices for Using Sub Flow

* Use Sub Flow for logic that is reused in multiple Microflows
* Keep sub flows focused on a single responsibility
* Clearly define input and output Business Objects
* Avoid deeply nested sub flows to maintain flow readability
* Use meaningful names for sub flows to reflect their purpose

***

### Summary

The **Sub Flow** node is a powerful mechanism for **modularizing integration logic** in ONEWEB Microflows.

By using Sub Flow, developers can:

* Structure large integration flows into manageable components
* Reuse common logic consistently
* Improve clarity, maintainability, and scalability
* Enforce clean architectural boundaries

Sub Flow plays a crucial role in building **robust, maintainable, and enterprise‑grade integrations** using ONEWEB.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/oneweb-platform-th/building-apps/integrations/develop-integration-with-oneweb-microflow/activity-nodes/sub-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
