# Workflows

## Overview

A [workflow](https://en.wikipedia.org/wiki/Workflow) consists of an orchestrated and repeatable pattern of activity, enabled by the systematic organization of resources into processes that transform materials, provide services, or process information.

A [Laboratory Information Management System (LIMS)](https://www.labii.com) allows you to effectively manage the flow of samples and associated data to improve lab efficiency. A [LIMS](https://www.autoscribeinformatics.com/resources/blog/what-is-a-lims) helps standardize workflows, tests, and procedures while providing accurate controls of the process. Instruments may be integrated into the LIMS to automate the collection of test data, ensuring they are properly calibrated and operated by trained staff only.

[Labii ELN & LIMS has integrated a sophisticated workflow management system to guide our users to document the data with a predefined process.](https://www.labii.com/blogs/AU53KxetBwJbnQ44Z0z-automatic-your-pipeline-with-workflows-in-labii-lims/)

This documentation demonstrates how to create a workflow and add steps. As the name implies, this is a new feature and is different from the previously used Workflows widget (now referred to as [Flowchart](https://docs.labii.com/widgets/section-widgets/process-management/flowchart) widget).

{% embed url="<https://youtu.be/uTNnvhBLhcg>" %}

## List of workflows

The list of workflows can be managed by clicking **Settings** on the side menu and then clicking **Workflows**.

![](https://3607108856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHVg57XIRcjV-Vbubtn%2Fuploads%2Fgit-blob-76dd56e263e2463d14fee7dec65814d2c5b8c0fc%2Fsettings-workflows-list.webp?alt=media)

### Search workflows

You can search a workflow by typing a keyword into the search bar in the **workflow list view,** and then clicking **Search**. The search results can always be cleared by clicking the **Clear** button.

### Filter workflows

With the **Filter** function, you can limit the number of workflows displayed. You can do that by clicking **Active workflows** and then selecting a filter from the dropdown. Here are a list of filters:

* **All workflows**. Filter to display all workflows.
* **Active workflows**. Filter to display the workflows that is active.
* **Archived workflows**. Filter to display the workflows that is archived

## Workflow detail

The details of a workflow can be viewed by clicking its name.

A workflow typically has these columns:

* **Sid** - the id of the backup
* **Name** - name of the backup
* **Description** - the description of the backup
* **Order** - the order of the workflow
* **Trigger** - Workflow triggers are events that cause a workflow to execute.
* **Actions** - Actions are the functions that the workflow will execute.

### Trigger

Trigger is the condition to execute the workflow. The trigger is optional. The workflow will be executed automatically if trigger is provided. In the absence of a trigger, the workflow can be manually triggered.

<figure><img src="https://3607108856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHVg57XIRcjV-Vbubtn%2Fuploads%2Fgit-blob-311ec5336421299b576e1fb0ff41acd706695b38%2Fsettings-workflows-trigger.webp?alt=media" alt=""><figcaption></figcaption></figure>

* **Events or schedule** - Event or schedule to trigger the workflow.
  * **Record created**, triggered by the creation of a record.
  * **Record updated**, triggered when a record is updated.
  * **Interval schedule**, triggered by an interval schedule.
  * **Crontab schedule**, triggered by an crontab schedule.
* **Record created**
  * **Trigger table** - The table of record that will trigger the workflow when a certain event occurs to it.
  * **Condition** - The conditions that must be met before a workflow is executed. You can skip the conditions check by leaving it empty.
    * **Field** - The fields/columns of the table table name.
      * **Lookup expression** - Lookup Expression or Method
      * **Value** - Value or term to lookup.
  * **Logical operator** - Logical operator is used to determine the logic between conditions.
* **Record updated**
  * **Trigger table** - The table of record that will trigger the workflow when a certain event occurs to it.
  * **Trigger column** - The column of record that will trigger the workflow when updated.
  * **Condition** - The conditions that must be met before a workflow is executed. You can skip the conditions check by leaving it empty.
    * **Field** - The fields/columns of the table table name.
      * **Lookup expression** - Lookup Expression or Method
        * **Value** - Value or term to lookup.
  * **Logical operator** - Logical operator is used to determine the logic between conditions.
* **Interval schedule**
  * **Interval value** - A positive number.
  * **Interval unit** - The unit of time.
    * Minute(s)
    * Hour(s)
    * Day(s)
* **Crontab schedule**
  * Minute(s)
  * Hour(s)
  * Day(s) Of The Week
  * Day(s) Of The Month
  * Month(s) Of The Year
  * Cron Timezone

### Actions

Actions are the functions that the workflow will execute. Labii use API calls to perform the actions. Learn more at <https://docs.labii.com/api/sdk>.

<figure><img src="https://3607108856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHVg57XIRcjV-Vbubtn%2Fuploads%2Fgit-blob-8a42579806c88aaa0fbefd35b0b2b7226224d49b%2Fsettings-workflows-actions.webp?alt=media" alt=""><figcaption></figcaption></figure>

Each action contains the following fields:

* **Method** - API Method
  * **Create**- The POST method to create a object.
  * **Modify** - The PATCH method to modify a object.
* **Object**
  * **Record** - The data record
  * **Cell** - The column data of a record
  * **Section** - The section of a record
  * **Notification** - The notification object
* **Query or SID -** Additional query to limit the results. If method='Modify' or 'Delete', provide the SID here.
* **Data -** Data in JSON to be created or modified.

## Add workflow

A workflow can be created by the administrator. To do that:

1. Click the **Settings** at the side menu, and then select **Workflows**
2. Click the "**+ Add Workflow**" button
3. A form will be displayed.
4. Provide name and description of the backup
5. Click **Submit** button

## Delete workflow

**Delete workflow at the list view**

To delete a workflow, go to the list view of workflow and then click the **Delete** icon.

**Delete workflow at the detail view**

Open a workflow and then click **Delete** button.

## Execute workflow

If the trigger is defined, the workflow will be executed automatically.

Furthermore, you can manually trigger workflows using the following methods:

1. [From record submit form](https://docs.labii.com/user-guide/add-record#execute-workflows).
2. [From import form](https://docs.labii.com/user-guide/list-view/import#step-1-select-file).
3. [From Flowchart widget](https://docs.labii.com/widgets/section-widgets/process-management/flowchart).
4. [From trigger schedule](#trigger)

## Execution Log

The Execution Log in Labii workflow serves as a comprehensive record detailing the who, when, why, and what of each workflow execution. It captures crucial information such as the timestamp of execution, identifying the user responsible, the trigger event that initiated the workflow, and the detailed outcome or result of the execution. This log not only provides a chronological overview of workflow actions but also enables users to track the history and status of their workflows, facilitating transparency and accountability in workflow management.
