---
entityname: Flow
entitynamelowercase: flow
alias: user-guide-create-flow
description: "Create and manage automated material flows within a system, defining steps and conditions for processing"
---
# Create Flow
:lock: Flow.**Create**
## Overview
This operation is used to create a **Flow**. For more information, see the [[tutorials-flowmodeling|]] Tutorial.
## Setup
No specific setup is required other than to meet the preconditions of the transaction.
## Preconditions
* The **Flow** does not currently exist in the system.
## Sequence of Steps
{% include-markdown 'includes/pages/info_creating_versioned_entities.md' %}
### Step 1: Change Set
{% include-markdown 'includes/pages/step_one_versioned_entities.md' %}
### Step 2: General Data
1. Provide a name for the **Flow**.
!!! warning
A Flow name may not contain the following characters: `:` and `/`.
2. If you are creating a new version, the revision that was selected when you started the process will be the revision to which this version will be associated. If you are creating a new entity or revision (with a new version associated to it), provide a name for the revision or it will be automatically generated for you. For more information on revision naming, see [Revision Naming](../../../general/revisions#Naming/).
3. Optionally, provide a description of the **Flow**.
4. Select the **Flow** type. The list of possible values is taken from the lookup table [[flowtype-lt]].
5. Select the type of **Flow**:
* Sequential
* Alternate (choose Single or Multiple Selection)
* Non-Sequential Block
* Line
!!! warning
Non-Sequential Block Flows or Line Flows can only contain Steps.
6. Set the **Flow** as enabled or disabled.
!!! info
A disabled Flow prevents any Material from being assigned to that Flow, whether from traditional creation or through rework, adjustment or any other reason. However, if the Material already exists in a Flow that is disabled, processing can continue normally.
7. Select **Create** to complete the transaction and a new object will be created.

### Step 3: Flow Items
At this point the **Flow** is created but there are no **Steps** or **Flows** defined for it. To start building the **Flow** structure, select the :material-pencil: button in the center of the window.

To add to the **Flow** structure, select either **Add Step** or **Add Flow**. This action will insert a new row will into the structure.
{width=600}
Compose the structure of the **Flow**, bearing in mind the following restrictions:
* A **Flow** cannot be empty - it must have at least one Child Flow or one **Step**.
* When a **Flow** has Steps, the last **Step** cannot be an optional **Step** (even in the case of a Non-Sequential block, although it can be performed at any time).
* A **Flow** which is Alternate cannot have Optional Steps.
* A **Flow** which is Non-Sequential Block cannot be Alternate.
* A **Flow** which is Non-Sequential Block cannot have duplicated Steps.
Each **Step** added to the **Flow** can be customized as outlined by the table below:
| Flow Type | Optional | Line Step | Skippable |
|-----------|-----------|-----------|-----------|
| Sequential | X | X | X |
| Non-Sequential Block | X | X | X |
| Alternate | | X | X |
| Line | X | | |
Table: Flow Types and Step Options
!!! note
The Skippable option is only used in the context of Experiments. For more information, see [[user-guide-create-experiment-definition]].
You can add any desired **Flow Item** to the structure and rearrange it as needed during the editing process.

!!! info
If a Step has defined any Logical Names, the same Logical Names can be selected for the Flow, in order to represent a specific logical Step. For more information, see [[tutorials-flowmodeling#logical-names|Flow with Logical Names]].
### Optional Flow Items
Optional **Flow Items**, whether **Step** or **Flow**, can be skipped during the process. The decision to skip is made when moving the **Material** to the next **Flow** or **Step**, either manually or via a business rule.
You can define conditions for optional **Flow Items** and those in Alternate **Flows** to determine the next **Steps** for a **Material**, based on its state and characteristics. These conditions are set by the Condition Type property and include the following types:
=== "Expression"
Requires a [Case Sensitive](#case-sensitivity) expression in [JSONata](https://jsonata.org/) that evaluates the state of the Material and returns `true` or `false`. This expression can reference direct properties, attributes, and characteristics of the Material, as well as properties of its Product, Product Group, and Step. Some examples are:
- Material Primary Quantity is greater than 100: `PrimaryQuantity > 100`
- Material name contains the value "Material A": `$contains(Name, 'Material A')`
- Material Is Hot set to `true` or `false`: `IsHot = true` or `IsHot = false`
- Step name equals "Step A": `Step.Name = 'Step A'`
- Product Group default units are "Kg": `Product.ProductGroup.DefaultUnits = 'Kg'`
- Attribute 'RetailPrice' is greater than 100: `Attributes.RetailPrice > 100`
- Material Characteristics 'Color' is equal to "Red": `MaterialCharacteristics.Color = 'Red'`

#### Case Sensitivity
JSONata is case sensitive by design. This means that an expression must respect the casing of the properties it references, as it can cause issues when comparing values if the actual value is stored in any other casing variation.
A workaround to the **case sensitivity issue** when comparing JSONata expressions is to use the built-in `$lowercase()` or `$uppercase()` functions to normalize both sides of the comparison.
See the example below:
```js
$lowercase(MaterialCharacteristics.Color) = $lowercase("Black")
// true if Color is "BLACK", "black", "Black", and other case variations
```
This ensures that expressions behave consistently by converting values to the same case before comparison.
=== "Rule"
Involves a Rule linked to a DEE Action of scope 'Flow Item Evaluation', returning `true` or `false`.

=== "Step Sampling"
The Step Sampling condition determines whether a Material should enter an optional Step for sampling based on a Sampling Plan. When a Step is marked with this condition, CM MES evaluates the associated Sampling Plan at the designated Sampling Evaluation Step to decide if the Material should be processed for inspection or proceed directly to the next Step.

=== "Sampling Plan"
The Sampling Plan condition applies a specific Sampling Plan directly to a Step. When this condition is set, CM MES selects Materials for sampling based on the plan’s frequency rules (counter-based or time-based) and processes them in that Step.

!!! info
Only Flow Items of type Step in Flows other than Non-Sequential Blocks or Alternate Flows can use Step Sampling or Sampling Plan as Condition Types.
When adding a condition of type Step Sampling, you must ensure that the selected Sampling Step exists in the Flow before the Step being configured.
### Rework Paths
If Rework Paths need to be configured, after saving the **Flow** structure, select the **Step** for which Rework Information will be added, go to the right side of the **Step** section, select the three vertical dots and choose **Step Configuration**.
Use the :material-plus: and :material-trash-can: icons to add or remove Rework Paths for the **Step**. For each Rework Path, specify:
* **Reason**, that is applicable for Rework at that **Step**, which will indicate the default Rework Path for that a given **Reason**.
* **Go To Flow Path**, the **Flow** and **Step** where the **Material** should be sent for Rework.
* **Return Flow Path**, where the **Material** will return after it reaches the last **Step** of the Go to Flow Path. The **Material** will return automatically after the Move Next from the last **Step** of the Go to Flow Path. For convenience, use the Browse button to select the Return Flow Path directly from the Flow structure.
* **On Rework Rule** (optional), that will be executed when a **Material** follows a given Rework Path.
* Toggle **Applicable to Queued** and **Applicable to Processed** to indicate whether the Rework Path applies to **Materials** in Queued and Processed states, respectively.

After completing your edits, select **Save** on the top ribbon to update the **Flow** and complete the transaction. At anytime you may select the [[user-guide-view-rework-paths]] button to access the Rework Paths configured.
### Rules on Enter/Exit Step
You can define **Rules** to be run when a **Material** enters or exists a **Step**. These **Rules** are linked to **DEE Actions**, enabling you to execute custom code to be triggered when entering or exiting a specific **Step**.
The management of these **Rules** is handled by the **Flow** structure. In the Edit Flow Structure view, you can select a **Rule** with the scope Material Tracking to be executed for Enter and Exit events of **Flow Items** of type **Step**. This functionality is controlled by the On Enter Rule and On Exit Rule properties of the **Flow Item**.
