> For the complete documentation index, see [llms.txt](https://oresund-integration-platform.gitbook.io/oresund-integration-platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oresund-integration-platform.gitbook.io/oresund-integration-platform/about/product-and-developer-guide/adapters/subloop-helper.md).

# Subloop Helper

**T**he subloop helper operation involves calling one or more i-flows from the first i-flow, which has various limitations such as different pagination functionality or an API with a hierarchical structure. It is also possible to separate a module of business logic into a sub-flow, thereby reducing the complexity of understanding the flow structure.

## <mark style="color:blue;">Architecture</mark>

<figure><img src="/files/VzmywFxbcs8BeHipd63i" alt=""><figcaption></figcaption></figure>

## <mark style="color:blue;">Functionality</mark>

To trigger one i-flow inside another, we can use a subloop helper. For instance, if we need to fetch the last five days' data repeatedly, a single i-flow cannot do so because we must retrieve data page by page. Instead, we use a subloop helper to generate a list of the last five dates, pass it to the subloop i-flow, and fetch all data from the first page to the last page. The subloop helper triggers i-flows through the jobInvoker.jobSync() method, and we can store previous step data and API-required data in the RequestObject.Data property via step settings and responseFormatter of the subloop step. The RequestObject data is stored in the Configs\['0'] of a new ObjectHolder in the job sync method, and a new object holder instance is created every time the subloop job is triggered. As usual, the subloop steps' request and response data are stored in the step history, and if an error occurs, it is caught in the IIF. We can trigger the subloop job once or more times, depending on the client's requirements.

## <mark style="color:blue;">Prerequisites</mark>

* The response formatter of the step allows passing the previous step's data in all formats. To call a sub-loop flow, the step type should be chosen as SUBLOOP in the step type.&#x20;
* The sub flow's name with the exact case type should be given in the step's path where it is desired to call it.&#x20;
* If it is necessary to pass any previous step data in string format in the step settings, it can be passed both statically and dynamically.

#### Limitations

* If it tries to pass any big information from the main flow it can end up in a nested exception or infinite loop. So only specific minimal information required to trigger the sub-I-flow can be passed.
* The client should be the same for both the main I-Flow and the sub-I-Flow.
* The Subloop I-flow’s scheduled date & time is taken from the main I-flow.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://oresund-integration-platform.gitbook.io/oresund-integration-platform/about/product-and-developer-guide/adapters/subloop-helper.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.
