--- alias: tutorials-sampling-plan-flow-conditions title: Configuring a Sampling Plan in a Step and Flow description: "Configure Sampling Plan and Step Sampling conditions in a flow" --- # Configuring a Sampling Plan in a Step and Flow After you create the **Sampling Plan**, apply it through conditions in the [[user-guide-create-flow|Flow Structure]]. The conditions are **Step Sampling** and **Sampling Plan**. ## Sampling Plan The **Sampling Plan** condition determines a Material's eligibility for sampling according to the configuration specified in the **Sampling Plan**. For more details on flow conditions, see [[user-guide-create-flow]]. ### Scenario In a sterile syringe manufacturing line, each **Syringe** goes through **Molding**, **Assembly**, **Plunger Insertion**, **Sterilization**, and **Marking**. At the **Sterile Integrity & Seal Inspection** step, the **Sampling Plan** determines whether each lot is sampled. For example, Critical Manufacturing MES may require sampling every hour. When **Syringes** reach this step, the system selects only the eligible lot for sterile integrity and seal-strength testing, while the remaining lots proceed directly to the next step. This ensures compliance with medical safety standards and verifies sterility and sealing quality without slowing high-volume production. ### Configuration * Create the necessary Critical Manufacturing MES entities to support the scenario, such as **Steps**, **Flows**, **Resources**, and **Services**. * Create a **Sampling Plan** of type **Time-Based** with a **Time Frequency** of `1` hour (`SP_PressureTest`). ![Screenshot showing a time-based Sampling Plan used for flow configuration.](../images/sampling_11.png) !!! tip For other cases, [[user-guide-manage-instances-sampling-plan|Sampling Plan Instances]] can be added according to the defined Contexts. For example, for a different Product, the Sampling Time Frequency can vary. The Last Sampling Date can also be updated if appropriate. * Create a new version of the **Flow** and mark the **Sterile Integrity & Seal Evaluation** step as **Optional**. * Add the condition **Sampling Plan** and select `SP_PressureTest`. ![Screenshot showing the flow step configured as optional.](../images/sampling_12.png) ![Screenshot showing the Sampling Plan condition applied in the flow.](../images/sampling_13.png) ### Execution On the [[user-guide-sampling-plan-page|Sampling Plan]] page, in the **Instances** section, you can verify that for the defined **Material Product** context, the system selects one **Material** belonging to that **Product** for sampling every hour. In this example, the **Last Sampling Date** is `12:16 PM`, which means the next **Material** selected for sampling will occur from `1:16 PM` onward. ![Screenshot showing Sampling Plan instances for the configured context.](../images/sampling_14.png) Until one hour has passed since the last sampled **Material**, **Track-Out & Move-Next** skips the optional **Step** of the **Flow** where the **Sampling Plan** condition is defined for every **Material** of the specified **Product** instance. ![Screenshot showing a material skipping the optional step before the sampling interval is met.](../images/sampling_15.png) ![Screenshot showing the flow path taken before the next sample is due.](../images/sampling_16.png) Once the hour passes, the system selects the next **Material** belonging to the specified **Product** instance for sampling and processes it in the **Step** where the **Sampling Plan** applies. ![Screenshot showing a material selected for sampling after the time condition is met.](../images/sampling_17.png) ![Screenshot showing the flow path when the material is routed to the sampling step.](../images/sampling_18.png) !!! tip You can apply the same or a different Sampling Plan to two or more sequential Steps. As a result, the system can skip two or more consecutive Steps. See this scenario demonstrated in the following video: {% set video_id = '0227a34ea314a42a228ae5bf429cf9c0' %} {% include-markdown 'includes/cloudflare_stream.md' %} ## Step Sampling **Step Sampling** is a condition available in the [[user-guide-create-flow|Flow Structure]] for **Flow Items** that are optional. Its purpose is to evaluate whether a **Material** qualifies for sampling according to the sampling configuration defined for the selected **Step**. ### Scenario In an automotive assembly line, **Engines** pass through multiple production **Steps**. During the **Cylinder Honing** step, Critical Manufacturing MES evaluates whether a lot should later be inspected based on a **Sampling Plan**, in this case every 10th **Engine**. The **Engines** continue through assembly normally, and only the previously selected **Engines** perform the **Torque Inspection** step. This ensures machining quality is monitored without slowing down the line, as the inspection is performed at the stage where torque can actually be measured. ### Configuration * Create the necessary Critical Manufacturing MES entities to support the scenario, such as **Steps**, **Flows**, **Resources**, and **Services**. * Create a **Sampling Plan** of type **Counter-Based** with a **Counter Frequency** of `10`. ![Screenshot showing a counter-based Sampling Plan used for step sampling.](../images/sampling_19.png) !!! tip For other use cases, [[user-guide-manage-instances-sampling-plan|Sampling Plan Instances]] can be added according to the defined Contexts. For example, for a different **Product**, the Sampling Counter Frequency can vary. The Current Sampling Counter can also be updated if appropriate. * Define the **Cylinder Honing** step as the **Sampling Plan Evaluation Step** for the **Sampling Plan** `SP_TorqueSampling`. For configuration details at the step level, see [[user-guide-manage-sampling]]. ![Screenshot showing the sampling evaluation step configuration.](../images/sampling_20.png) * Mark the **Torque Inspection** step as **Optional**. * Add the condition **Step Sampling**, selecting **Cylinder Honing** as the **Sampling Step**. ![Screenshot showing the Torque Inspection step marked as optional.](../images/sampling_21.png) ![Screenshot showing the Step Sampling condition configured in the flow.](../images/sampling_22.png) ### Execution On the [[user-guide-sampling-plan-page|Sampling Plan]] page, in the **Instances** section, you can verify that for the defined **Material Product** context, the system selects every 10th **Material** belonging to that **Product** for sampling. In this example, the **Current Sampling Counter** is `1`, which means the next **Material** selection for sampling will occur once the count reaches `10` at the **Sampling Step** `Cylinder Honing`. ![Screenshot showing the current sampling counter in the Sampling Plan instance.](../images/sampling_23.png) Until the **Current Sampling Counter** reaches the 10th **Material**, **Track-Out & Move-Next** skips the optional **Step** of the **Flow** where the **Sampling Plan** condition is defined for every **Material** of the specified **Product** instance. ![Screenshot showing materials skipping the optional inspection step before the counter threshold is met.](../images/sampling_24.png) Once the **Current Sampling Counter** reaches the 10th **Material**, meaning 10 **Materials** of that **Product** have been processed in the **Cylinder Honing** step, the system selects that **Material** for sampling and processes it in the **Step** where the **Sampling Plan** applies. ![Screenshot showing the material routed to the inspection step when the counter threshold is reached.](../images/sampling_25.png) ![Screenshot showing the resulting flow after the 10th material is selected for sampling.](../images/sampling_26.png) For more information about **Sampling Plan** conditions, refer to [[user-guide-create-flow]]. See this scenario demonstrated in the following video: {% set video_id = '78da0116d6f1857f6d7221f14e837f15' %} {% include-markdown 'includes/cloudflare_stream.md' %}