# State Transitions

This tutorial explains how to add or edit a state transition within the OMS screens. State transitions play a crucial role in managing package and transfer operations efficiently.

## <mark style="color:red;">Step 1: Access State Transitions​</mark> <a href="#step-1-access-state-transitions" id="step-1-access-state-transitions"></a>

* To add a new state transition, start by selecting the **Settings** tab under the Akinon OMS menu.
* Next, click on **State Transitions**.<br>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FcdqGEn9Q6N661gyUALBh%2Fimage.png?alt=media&#x26;token=eeb20392-f4c3-4755-aaf3-40b0e5d596ae" alt=""><figcaption></figcaption></figure>
* Click on the **+New State Transition** button to add new state transition.<br>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FcGMbkcaU7eC2MBOK7dmo%2Fimage.png?alt=media&#x26;token=db7ea6a6-3149-4010-8d78-5cbfa64c6ad7" alt=""><figcaption></figcaption></figure>
* You can visualize the state transition flowchart by clicking the **Show Flowchart** button.<br>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F5RTttJ5iXn4rwUcvZr1U%2Fimage.png?alt=media&#x26;token=046bf8cc-4dc8-4ba1-92bd-43edc3dca927" alt=""><figcaption></figcaption></figure>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FF4GrFGTOdUd6xWQh3qG7%2Fimage.png?alt=media&#x26;token=240f2899-c10a-440b-bbb4-2baacce05001" alt=""><figcaption></figcaption></figure>
* To edit an existing state transition, follow the same steps to access **State Transitions** under the **Settings** tab. Select the state transition you want to edit from the list and proceed to its details.

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F66UVUYKG2HPYoBgqP9rB%2Fimage.png?alt=media&#x26;token=f9016f00-8014-4a53-9490-cebd6016db62" alt=""><figcaption></figcaption></figure>

## <mark style="color:red;">Step 2: Define State Transition​</mark> <a href="#step-2-define-state-transition" id="step-2-define-state-transition"></a>

A state transition is defined by completing the form on the state transition detail page. These defined state transitions facilitate package and transfer operations. Here are the fields you need to fill:

* **Command Name**: Provide a name for the state transition. This name will be displayed on the Package/Transfer detail page.
* **Source State**: This state varies depending on the specified command. It's essential to select the appropriate source state for the command to run successfully. Otherwise, you will receive an error code. This represents the state of the package, transfer, or shipment record before the command is run. (Listed in detail for each command).
* **Destination State**: This state varies depending on the specified command. It's essential to select the appropriate target state for the command to run successfully. Otherwise, you will receive an error code. This represents the state of the object. (Listed in detail for each command).
* **Command Code**: Select from the list of executable commands. Ensure that the Source and Destination States are selected correctly to display available options in the Command Code field.
* **Slug**: Enter a unique value to distinguish this state transition from others.
* **Visibility**: Determine where the command should be visible: Third Party, OMS Web, and Instore options are available.
* **Configuration**: If specific settings are required for the defined command, add them in JSON format.

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FOL87787e9abGqcz5oJVu%2Fimage.png?alt=media&#x26;token=168ad0e2-b590-4108-94d3-70aff59a17b9" alt="" width="375"><figcaption></figcaption></figure>
* **Command Condition**: Apply a condition for the state transition using one of four options:

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FaP2E8HcDMzawr3Jm9pnn%2Fimage.png?alt=media&#x26;token=5c19a32f-eac7-404f-a2ef-a349346ae35a" alt="" width="375"><figcaption></figcaption></figure>

## <mark style="color:red;">State Transition Example:</mark> <mark style="color:red;"></mark><mark style="color:red;">`COMPLETE_PACKAGING`</mark><mark style="color:red;">​</mark> <a href="#state-transition-example-complete_packaging" id="state-transition-example-complete_packaging"></a>

* In this example, the `COMPLETE_PACKAGING` command will be defined:
  * **Source State**: Select one of the states ("Waiting," "Preparing," or "Ready for Packaging") before the packaging order is moved to the desired status. Otherwise, validation error will be triggered.
  * **Destination State**: Set the target state as "Packed All Items".
  * **Command Code**: Select the `COMPLETE_PACKAGING` command for completing the packaging.
  * **Slug**: Add a unique value to distinguish this state transition.
  * **Visibility**: Enable the Third Party option to make the command visible on that platform. However, it should remain unselected if there's no intention to make these options visible on any of the panels.
* Clicking **SAVE** will finalize the definition of the command, allowing it to update the state of a packaging order from “Waiting” to “Packed.”

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FyT69il0fO9C5Lu2wkj3T%2Fimage.png?alt=media&#x26;token=64463c05-e271-4530-b539-5425d3719f7f" alt="" width="375"><figcaption></figcaption></figure>
