--- pdfexport: true alias: tutorials-business-workflows-business-event timetoread: true tutorial: full render_macros: false description: "This documentation guides users through designing automated business workflows within a manufacturing MES system using a visual interface, focusing on" --- # Business Workflows **Business Workflows** is a tool within Critical Manufacturing MES that allows users to design DEEs using a low-code visual interface with drag-and-drop tasks. It is ideal for building workflows to address simple scenarios and is managed as a system-versioned entity. These applications can be used for standalone functions or event handling. In this tutorial, we'll focus on the event handling use case. This tool is designed for users who are not IT experts, but who have a basic understanding of workflows, which you will have at the end of this tutorial. ??? Question "Standalone or Business Event" Before we begin, take a moment to reflect: What would you configure in the following examples? What feels right to you? - A scenario where whenever Hold Material is performed, the Resource where the Material is needs to transition to the Unscheduled Down state. Would this be a Business Workflow of type Business Event or Standalone? If you answered business event, you are correct. - A scenario where a button on the Resource View exists to, with one click, change the state of the Resource to Unscheduled Down. Would this be a Business Workflow of type Business Event or Standalone? If you answered standalone event, you are correct. ## Overview In this tutorial, our goal is to walk through three progressively complex scenarios, each reflecting possible use cases in a client factory environment: - Shipping a Material - Preventing a Material from starting production - Placing a retrieved Material to start production Throughout these scenarios, we'll explore the following key concepts: - Business Event Tasks - Material, Resource and Notification MES tasks - Reference Syntax - Addition of inputs and setting override ## Syntax Before diving in, it is important to understand the syntax used to reference data that will be used as inputs in your workflow. Each task available in the workflow has a unique name, along with its defined inputs and outputs. To reference this data, there is a structure to be followed. If you want to access the input of a given task, this is the syntax used: `{{$task_name.input_or_output_name}}`. - Example: `{{$MaterialTrackOutPost_1.Material}}` If you want to access properties within the input of a give task, this is the syntax used: `{{$task_name.input_or_output_name.property_1.property_2.[...].property_n}}`. - Example: `{{$MaterialTrackOutPost_1.Material.LastProcessedResource.Type}}` To know more about this, check out [[user-guide-business-workflow-task]]. ## Scenario: Ship Material Consider a production context with multiple production **Flows**, where the final **Step** in each **Flow** is a pass-through **Step** with the Allow Shipping flag set to true. The requirement is: when a **Material** reaches these **Steps**, it should be automatically shipped to a new **Facility** - the Distribution Center. ### Configuration To configure this scenario in the system, we start by identifying the trigger. What initiates the workflow? The answer is: when the **Material** changes **Step**. This leads us to select the Business Workflow event **Material.ChangeStep.Post.** Next, the system must evaluate the current **Step** the **Material** has reached. This highlights the need for a **Logic Task If**, where the condition checks if the Is Shipping Allowed property of the **Step** is set to true. If so, the **Material** should be shipped to the Distribution Center, which requires the use of the **MES Material Task Ship**. Follow the tabs below, from left to right, to navigate through the resulting configuration: === "Business Event Task" ![General](../../images/business_workflow_ship_scenario_general.png) === "Logic Task If" ![If](../../images/business_workflow_ship_scenario_if.png) === "MES Material Task Ship" ![Ship](../../images/business_workflow_ship_scenario_ship.png) Here's a step-by-step breakdown of the configuration process: 1. Start by creating a new Business Workflow. Select the Business Event best suited for this scenario: - **Material.ChangeStep.Post** 2. Drag and drop the **Logic Task If**, and set the following condition: - `{{$MaterialChangeStepPost_1.Material.Step.IsShippingAllowed==true}}` 3. Drag and drop the **MES Material Task Ship**, and configure its inputs: - Material: `{{$MaterialChangeStepPost_1.Material}}` - Facility: Distribution Center 4. Save and set this version as effective. ??? note "See more information about these tasks here" - [[user-guide-business-workflow-task-condition]] - [[user-guide-business-workflow-task-material-ship]] You can find the exportable file of this scenario here: [XML File](business-workflow-scenarios/business_workflow_first_example.xml). ### Testing Preconditions: - Ensure there is a **Flow** with a **Step** where shipping is not allowed — this is where the **Material** should initially be. - Define another **Step** with the Is Shipping Allowed property set to true, either within the same **Flow** or in a different one. - Confirm that **Facility** relationships are configured to allow shipping between the current location and the Distribution Center. Test scenario: - Perform a Move Next on a **Material**, where the next **Step** has shipping allowed. - Alternatively, perform a Change **Flow** and **Step** to one where shipping is allowed. - In both cases, the **Material** should transition to `In Transit`, indicating that it was successfully shipped. ## Scenario: Prevent Material from Starting Production Consider a manufacturing scenario where a minimum of 10 units of the primary quantity of the Material is required for production to begin. The requirement is: if a **Material** is dispatched and this minimum is not met, it should automatically be placed on hold with the "Quantity Below Minimum" **Reason**, and the **Resource** should transition to the `Unscheduled Down` state. ### Configuration The trigger for this scenario is the dispatching of a **Material**, which means the appropriate Business Event for this workflow is **Material.Dispatch.Post**. Since there is a condition based on the primary quantity of the **Material**, we need to use a **Logic Task If** to evaluate whether the quantity is less than 10. If the condition is met, two actions should occur: - The **Material** should be placed on hold, using the **MES Material Task Hold** task. - The **Resource** where the **Material** was dispatched to should be set to the `Unscheduled Down` state, using the **MES Resource Task Change State** task. Follow the tabs below, from left to right, to navigate through the resulting configuration: === "Business Event Task" ![General](../../images/business_workflow_hold_scenario_general.png) === "Logic Task If" ![If](../../images/business_workflow_hold_scenario_if.png) === "MES Material Task Hold" ![Hold](../../images/business_workflow_hold_scenario_hold.png) === "MES Resource Task Change State" ![ChangeState](../../images/business_workflow_hold_scenario_changestate.png) Here's a step-by-step breakdown of the configuration process: 1. Start by creating a new Business Workflow. Select the Business Event best suited for this scenario: **Material.Dispatch.Post** 2. Drag and drop the **Logic Task If**, and set the following condition: `{{$MaterialDispatchPost_1.Material.PrimaryQuantity<10}}` 3. Drag and drop the **MES Material Task Hold**, and configure its inputs: - Material: `{{$MaterialDispatchPost_1.Material}}` - Reason: Quantity Below Minimum 4. Drag and drop the **MES Resource Task Change State**, and configure its inputs: - Resource: `{{$MaterialDispatchPost_1.Resource}}` - State: Unscheduled Down 5. Save and set this version as effective. ??? note "See more information about these tasks here" - [[user-guide-business-workflow-task-condition]] - [[user-guide-business-workflow-task-material-hold]] - [[user-guide-business-workflow-task-resource-change-state]] You can find the exportable file of this scenario here: [XML File](business-workflow-scenarios/business_workflow_second_example.xml). ### Testing Preconditions: - The **Resource** to be used must be in a state other than `Unscheduled Down`. - The Hold **Reason** must be created and associated with the **Step** being used. - The primary quantity of the **Material** must be less than 10. Test scenario: - Perform a **Material** Dispatch. - After dispatching, the **Material** should be placed on hold with the appropriate Reason, and the Resource should transition to the `Unscheduled Down` state. ## Scenario: Place Retrieved Material to Start Production Consider the scenario where the requirements are: if a **Material** is retrieved from the Warehouse **Step**, it should automatically be moved to the **Step** where production starts, by updating its **Flow** and **Step**. Additionally, a **Notification** should be sent indicating that the **Material** is ready for production. This notification must have the information about the **Product**, **Step**, and Facility associated with the **Material**. ### Configuration The trigger for this scenario is when a **Material** is retrieved, which means the appropriate Business Event is **Material.Retrieve.Post**. A condition must then be evaluated to ascertain whether the **Step** from which the **Material** is retrieved is the Warehouse **Step**. This requires the use of the **Logic Task If** task. If the condition is met, two actions should follow: - The **Flow** and **Step** of the **Material** should be updated, which calls for the use of the **MES Material Task Change Flow and Step** task. - A **Notification** should be sent, using the **MES Notification Task Create Notification** task. In this case, we'll use a general notification that dynamically displays the **Material** name, along with its **Product**, **Step**, and **Facility**. To achieve this dynamic content, we'll introduce a new concept: adding inputs to override task settings — such as the message content in the [[user-guide-business-workflow-task-create-notification]] task. #### Adding Inputs and Outputs To add new inputs or outputs, use the :material-plus: icon located on the left pane of the designer, on the input or output section. After clicking it: - Provide a name that starts with a letter and does not contain whitespaces or special characters. - Then, select the appropriate Type from the list of available options. - Lastly, define the Collection Type. !!! warning The data the Collection Type "Array" is currently not functional - this is due to the shared structure and logic between Connect IoT features and the Business Workflow feature. To know more about this, check out [[user-guide-business-workflow-task]]. Going back to the scenario, follow the tabs from left to right to see the resulting configuration for the first three tasks: === "Business Event Task" ![General](../../images/business_workflow_change_flow_scenario_general.png) === "Logic Task If" ![If](../../images/business_workflow_change_flow_scenario_if.png) === "MES Material Task: Change Flow and Step" ![Hold](../../images/business_workflow_change_flow_scenario_change_flow.png) To make it easier to read, you can see continue following the tabs from left to right to see the configuration of the **MES Material Task Create Notification** task: === "MES Material Task Create Notification 1/4" ![CreateNotificationI](../../images/business_workflow_change_flow_scenario_notification_I.png) === "MES Material Task Create Notification 2/4" ![CreateNotificationII](../../images/business_workflow_change_flow_scenario_notification_II.png) === "MES Material Task Create Notification 3/4" ![CreateNotificationIII](../../images/business_workflow_change_flow_scenario_notification_III.png) === "MES Material Task Create Notification 4/4" ![CreateNotificationIV](../../images/business_workflow_change_flow_scenario_notification_IV.png) Here's a step-by-step breakdown of the configuration process: 1. Start by creating a new Business Workflow. Select the Business Event best suited for this scenario: **Material.Retrieve.Post** 2. Drag and drop the **Logic Task If** task, and set the following condition: `{{$MaterialRetrievePost_1.Material.Step.Name=="Warehouse"}}` 3. Drag and drop the **MES Material Task Change Flow and Step** task, and configure its inputs: - Material: `{{$MaterialRetrievePost_1.Material}}` - Flow Path: Production Flow:A:1/First Step:1 4. Drag and drop the **MES Notification Task Create Notification** task, and configure its settings and inputs: - Settings: - Name: *[Empty]* - Description: Material Ready For Production - Type: General (value must exist on [[notificationtype-lt]] Lookup Table) - Title: Default title (to be overriden) - Description: Default Description (to be overriden) - Severity: Information (value must exist on [[notificationseverity-lt]] Lookup Table) - Assignment: Everyone - applicable filer: None - Mode: Manual Single User - Inputs: - Add input - Name: Title - Type: String - Collection Type: None - Value: "`{{$MaterialRetrievePost_1.Material.Name}}` Material is ready for Production." - Add input - Name: Details - Type: String - Collection Type: None - Value: "Product: `{{$MaterialRetrievePost_1.Material.Product.Name}}` `` Step Name: `{{$MaterialRetrievePost_1.Material.Step.Name}}` `` Facility Name: `{{$MaterialRetrievePost_1.Material.Facility.Name}}`" 5. Save and set this version as effective. ??? note "See more information about these tasks here" - [[user-guide-business-workflow-task-condition]] - [[user-guide-business-workflow-task-material-change-flow-step]] - [[user-guide-business-workflow-task-create-notification]] You can find the exportable file of this scenario here: [XML File](business-workflow-scenarios/business_workflow_third_example.xml). ### Testing Preconditions: - The Warehouse **Step** must have a required storage **Service**, and there must be a **Resource** available to provide it. - The **Material** to be used should already be stored. - The Generic Table [[notificationseverity-gt]] must contain an entry for the configured **Notification** Type. Test scenario: - Perform **Material** Retrieve. - After retrieval, the **Material** should move to the defined Flow Path, and a **Notification** should appear displaying the **Material** name, **Product**, **Step**, and **Facility**. ### Final Notes #### Caption You can customize the caption of a task, which controls the text displayed on the block and its associated fields. While it is not mandatory and holds no functional impact, it can improve clarity and readability within the workflow. For example the default Caption for the **MES Material Task Hold** task is: - Hold Material `{{input.Material}}` with `{{input.HoldReason}}` **Reason**. ![DefaultCaption](../../images/business_workflow_default_caption.png) However, you can modify this caption by adding or removing appearance inputs in the task block. Here's an example of a customized version: - Hold Material `{{input.Material}}` with `{{input.HoldReason}}` **Reason** and if I wanted, I would be able to say the comment here `{{input.Comment}}` ![MyCaption](../../images/business_workflow_my_caption.png) For more information on caption, check out [[user-guide-business-workflow-task]]. #### Input Inputs are the data values required for a task (function) to execute. These values typically come from direct properties of entities referenced by "parent" tasks. No inherited Product Characteristics are available as inputs. Attributes are accessible if they were already loaded by the triggering operation, for example: `{{$MaterialTrackOutPost_1.Material.Attributes[""].ToString() == ""}}` Alternatively, you can use the following syntax as an example, which will load the attributes first if they haven't been loaded yet: `{{$MaterialTrackOutPost_1.Material[""]}}` Inputs can be either referenced dynamically or hardcoded. For example, assuming the task has an input called "Resource", you can: - Reference it dynamically: `{{$MaterialTrackOutPost_1.Resource}}` - Hardcode the value: `Baker-01` Both are valid, depending on the use case. For more information on inputs and syntax, check out [[user-guide-business-workflow-task]]. !!! note To check the correct property names, go to: Administration, Entity Types, then select the entity you need and open the Properties section. This is important because the name shown in the UI doesn't always match the actual property name. For example, in the Material Details View, the last Resource where the material was processed appears as "Last Resource", but the property name is actually `LastProcessedResource`. #### Output Some tasks come with automatically defined outputs, such as `{{$this.Material}}`. These outputs represent the result of the task itself and may be required by other system processes or dependencies. It is strongly advised not to remove these outputs, as doing so could impact the proper functioning of the workflow or system behavior as a whole. This syntax is not used as an input in other tasks—it's specific to the task's own context. For more information on outputs and syntax, check out [[user-guide-business-workflow-task]]. #### Tasks If you want to explore other tasks, checkout this [[user-guide-business-workflow-tasks-index]].