Work Order Attributes and Lifecycle

Work Order Attributes

Attributes of a Work Order can be divided into one of the following categories:

  • Core: These are the attributes mandated by the platform for Work Order entities. Some of these attributes are required.
  • System: These are system-defined attributes and can be modified only by Order Orchestrator.
  • Custom: These attributes are defined by the Tenant to enhance their usability. Tenants can define custom validations and also specify for them to be indexed or non-indexed.
CategoryAttribute NameData Type ExpectedDescription
CoreTenant IDUUIDThe ID of the tenant to whose realm the Work Order belongs.
SystemWork Order IDUUIDSystem generated unique ID.
CoreOrder IDUUIDThe Order to which this Work Order belongs.
CoreWork Order TypeVarCharEnum

- MOVE_CONTAINERS
- PHYSICAL_SERVICE
- DIGITAL_SERVICE
CoreDescriptionVarCharShort textual description of the work order.
CorePickup Address (optional)VarCharIn case a Work Order has Containers involved this field stores the pickup address for them.
CoreContainers (optional)ListList of Container IDs.
(Container details collected in platform order creation payload.)
CorePickup Quality Checks (optional)Object
CoreCollect Amount On pickup (optional)Boolean
CoreAmount to collect on delivery (optional)Amount ObjectAmount Object including currency code.
CustomCustom Attributes
1-to-n (indexed)
Key-valueCore attributes for a Work Order with indexing. The tenant will be able to configure validations, if required, for these attributes.
CustomCustom Attributes
1-to-n (non-indexed)
Key-valueCustom attributes for a Work Order without indexing. The tenant will be able to configure validations, if required, for these attributes.
SystemCurrent State (optional)VarChar
SystemCurrent Sub-state (optional)VarChar
SystemSchema Version (optional)IntegerThe version of the work order schema configuration (for custom attributes) that was used to create the order.
SystemCreated On (optional)Timestamp
SystemUpdated On (optional)Timestamp
SystemCreated By (optional)VarChar
SystemUpdated By (optional)VarChar

Creating Work Order Custom Attribute

To create a Work Order Custom Attribute, call the POST /work-order/config/attributes endpoint and pass the following parameters in the request body:

ParameterDescriptionValidationData type
nameName of the attribute.minLength: 1 maxLength: 32 pattern: ^[a-zA-Z]{1,32}$string
descriptionDescription of the attribute.minLength: 0 maxLength: 256 pattern: ^([a-zA-Z])([a-zA-Z0-9,\s]*)$string
datatypeThe data type of the Attribute.Valid values: string, number, boolean, object, array, moneystring
validationSpecifies all of the validations that are performed on the Attribute when an order of this type is created or updated.
indexedSpecifies whether the Attribute is indexed. Filter or search operation on the basis of a custom attribute is only allowed if this field is set as TRUE.boolean

The following sample payload shows how to create Work Order Custom Attributes named stringValidations and intValidations:

{
  "attributes": [
    {
      "name": "stringValidations",
      "description": "string",
      "indexed": true,
      "dataType": "string",
      "validation": {
        "range": {
          "min": 0,
          "max": 5
        },
        "regex": "string",
        "valueOneOf": [
          "string123",
          "string124"
        ],
        "required": false
      }
    },
    {
      "name": "intValidations",
      "description": "int",
      "indexed": true,
      "dataType": "number",
      "defaultValue": 1,
      "validation": {
        "range": {
          "min": 0,
          "max": 5
        },
        "valueOneOf": [
          0,1,2,3,4,5
        ],
        "required": true
      }
    }
  ]
}

Adding Work Order to an Order

To add a Work Order to an Order, call the PUT /{orderId}/work-order endpoint. The following sample payload shows how to add a Work Order to a Order:

[
    {
        "amountToCollectOnDelivery": {
            "currencyCode": "INR",
            "amount": 1000
        },
        "pickupQualityChecks": {},
        "collectAmountOnPickup": true,
        "description": "Testing first workorder",
        "type": "MOVE_CONTAINERS",
        "pickupAddress": "location:1234",
        "attributes": {
            "stringValidations": "string124",
            "intValidations": 1
        },
        "containers": [
            "container:001"
        ]
    }
]

Work Order Lifecycle

A Work Order has the following lifecycle states:

  • Created: This initial state signifies that the Work Order has been created but waiting to be processed by the Order Orchestrator.
  • In-Progress: This state signifies that the Work Order is currently under execution by the Order Orchestrator. Sub-states for this will be defined at the time of defining the Order Orchestrator.
  • Completed: This terminal state signifies that the Work Order has been executed either successfully or unsuccessfully. This state will have three predefined sub-states, i.e., Executed, Failed, and Canceled. There will be no transition allowed between these sub-states.