# Reusable Content

In order to keep up with DRY principle (Don't Repeat Yourself), Frends includes Subprocesses and Environment Variables to allow defining functionality and values once and reusing them in your Processes.

## Subprocesses

Subprocesses in Frends are like building blocks that help simplify complex integrations, much like functions or methods in other programming languages. They're reusable bits of Tasks and logic that you can run across different Processes.

<figure><img src="/files/hMOrjTdo37fu6Grjze9m" alt="Subprocess calls can be used similarly to tasks. They contain process logic similar to the main processes."><figcaption><p>Subprocess calls can be used similarly to Tasks. They contain Process logic similar to the main Processes.</p></figcaption></figure>

Essentially the only differences between "Main Processes" and Subprocesses are that you can only define a single Manual Trigger, which is used to provide parameters to the Subprocess to work on, and that Subprocesses can be called from Processes and other Subprocesses, while Processes cannot. Subprocesses can also be **called on unhandled errors** from Processes, making them the catch-block error handlers.&#x20;

<figure><img src="/files/ZtStMNgRsvNltIgatc6l" alt="Error handler subprocess can be used to process errors, that were not handled during process execution."><figcaption><p>Error handler Subprocess can be used to process errors, that were not handled during Process execution.</p></figcaption></figure>

Whenever you have a set of Tasks fulfilling an operation you need in multiple Processes, it becomes useful to separate that into a Subprocess instead. For example running AI Connector as a predefined AI agent with specific parameters, mapping and delivering customer data or performing authentication token query with a cache are all excellent uses of Subprocess.&#x20;

## Environment Variables

In case it is global values you need in multiple Processes, or values that are Environment specific, such as different credentials and connection points for testing and production environments, Environment Variables are there to take care of them.&#x20;

<figure><img src="/files/8m5K45JCOsQbvgGHigB9" alt="Environment variables are global values for each environment."><figcaption><p>Environment Variables are the global values for each Environment.</p></figcaption></figure>

Environment Variables are defined centrally in the Environment Variables section of Frends Control Panel, and can hold groups of values for different purposes. Values can be grouped together by their purpose, such as per target system or for specifically global error handling, and the values themselves can be textual, numerical, lists or secrets.&#x20;

As the key feature of Environment Variables, each Environment in your Frends Tenant can receive separate values for the same variable. This makes it easy to develop and test the integrations using test values and test environments as target systems, and when the Process is ready, it can be deployed to production without any changes to the Process itself, because the Environment-specific values are defined separately and centrally in Environment Variables.

<figure><img src="/files/q1ry7EdrCNLzlJ70CxKU" alt="Using environment variables is recommended for example for connection parameters."><figcaption><p>Using Environment Variables is recommended for example for connection parameters.</p></figcaption></figure>


---

# 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.frends.com/docs/frends-6.2.0/frends-development/integrations/reusable-content.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.
