---
title: "MES Work Order"
id: "mes-work-order"
project: "MES User Manual"
url: "https://docs.sepasoft.com/articles/user-manual/mes-work-order"
updated: 2026-07-31T14:56:41Z
---

# MES Work Order

**Sepasoft MES Module Suite**

###  MES Work Order

An instance of the MES Work Order object is created whenever a new work order is created using the [MES Work Order Table](https://help.sepasoft.com/docs/display/SEPA/MES+Work+Order+Table) component and also by the system.mes.workorder.createMESWorkOrder() scripting function. This object can then be used to adjust any of the parameters such as required quantity, due date and status. The actual quantity produced against a work order and remaining quantity are calculated based on the sum of quantities from operations associated with the work order ref UUID. Please note that these calculations can change based on the operations referencing the work order. The Work Order object has a method called "updateQuantities()" described below, which retrieves the latest values associated with the work order. This is part of the full object load, but is not part of loading the object from a link.

The MES Work Order object is derived from the MESAbstractObject and inherits all of its exposed properties, methods and events as well as adds the ones documented in this section.

* [MES Work Order](/articles/user-manual/mes-work-order/a/MESWorkOrder-Description)
* [Object Creation](/articles/user-manual/mes-work-order/a/h3_1429514382)
* [Use](/articles/user-manual/mes-work-order/a/MESWorkOrder-Use)
* [Object Properties](/articles/user-manual/mes-work-order/a/h3__944824966)
* [Object Functions](/articles/user-manual/mes-work-order/a/MESWorkOrder-ObjectFunctions)
* [getActiveOperationsResponses()](/articles/user-manual/mes-work-order/a/h4__80649587)
* [getActualMaterialLots(beginDate, endDate, lotUseType)](/articles/user-manual/mes-work-order/a/h4_1167254018)
* [getActualPersonnel(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4_1591175675)
* [getActualQuantity()](/articles/user-manual/mes-work-order/a/h4__2098013238)
* [getActualSupplementalEquipment(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4_1699588839)
* [getClosedDate()](/articles/user-manual/mes-work-order/a/h4__1141591755)
* [getDueDate()](/articles/user-manual/mes-work-order/a/h4_2145490167)
* [getMaterialRef()](/articles/user-manual/mes-work-order/a/h4__569210707)
* [getMaterialRefName()](/articles/user-manual/mes-work-order/a/h4__986599752)
* [getMaterialRefType()](/articles/user-manual/mes-work-order/a/h4__1830630347)
* [getMaterialRefUUID()](/articles/user-manual/mes-work-order/a/h4__599406076)
* [getOperationsRequests()](/articles/user-manual/mes-work-order/a/h4_1186028499)
* [getOperationsRequests(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4__1837112989)
* [getOperationsResponses()](/articles/user-manual/mes-work-order/a/h4_393433249)
* [getOperationsResponses(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4__2109659807)
* [getRemainingQuantity()](/articles/user-manual/mes-work-order/a/h4_1432535084)
* [getScheduledQuantity()](/articles/user-manual/mes-work-order/a/h4__1130228479)
* [getWorkOrderQuantity()](/articles/user-manual/mes-work-order/a/h4_1755886227)
* [isClosed()](/articles/user-manual/mes-work-order/a/h4__2140618815)
* [setClosed(closed)](/articles/user-manual/mes-work-order/a/h4_125988475)
* [setClosedDate(closedDate)](/articles/user-manual/mes-work-order/a/h4__2028550541)
* [setDueDate(dueDate)](/articles/user-manual/mes-work-order/a/h4__1226248445)
* [setMaterialRef(mesMaterialDef)](/articles/user-manual/mes-work-order/a/h4_77700932)
* [setMaterialRef(materialLink)](/articles/user-manual/mes-work-order/a/h4_1160383467)
* [setWorkOrderQuantity(quantity)](/articles/user-manual/mes-work-order/a/h4_1754314632)
* [updateQuantities()](/articles/user-manual/mes-work-order/a/h4_643090573)
* [Object Events](/articles/user-manual/mes-work-order/a/MESWorkOrder-ObjectEvents)

* * *

### Object Creation

The following scripting functions create an MES Work Order:

* [system.mes.workorder.createMESWorkOrder()](/articles/user-manual/system-mes-workorder-createmesworkorder)


```python
#Get a material link for the work order material
matLink = system.mes.getMESObjectLinkByName('MaterialDef', 'Soda')
   
#Create the work order
wo = system.mes.workorder.createMESWorkOrder('A34', matLink)
  
#Set some production related properties
wo.setWorkOrderQuantity(1000.0)
 
#Set the due date
wo.setDueDate(system.date.addDays(system.date.now(), 7))
 
#Save the object
system.mes.saveMESObject(wo)
```


### Use

The following scripting functions and components use this object.

* [system.mes.workorder.saveMESWorkOrder()](/articles/user-manual/system-mes-workorder-savemesworkorder)
* [system.mes.workorder.getMESWorkOrder()](/articles/user-manual/system-mes-workorder-getmesworkorder)
* [system.mes.workorder.getMESWorkOrders()](/articles/user-manual/system-mes-workorder-getmesworkorders)
* Vision MES Work Order Table component's Work Order User Event.[getWorkOrder()](/articles/user-manual/mes-work-order-table/a/get)

### Object Properties

Inherits properties from [AbstractMESObject](/articles/user-manual/abstractmesobject).

Property values can be accessed and changed for an object by using the getPropertyValue() and setPropertyValue() method.

These properties are accessible through the MES Work Order Table component and with the provided object functions, but not directly as obj.properties.

| Name | Scripting Name | Permissions | Description |
| --- | --- | --- | --- |
| Material Reference | MaterialRef | Read/Write | Material Definition assigned to the Work Order object. |
| Material Reference UUID | MaterialRefUUID | Read/Write | UUID of the Material Definition assigned to the Work Order object. |
| Material Reference Type | MaterialRefType | Read/Write | Type of the Material Definition assigned to the Work Order object. |
| Work Order Target Quantity | WorkOrderQuantity | Read/Write | Target quantity assigned to the Work Order object. |
| Work Order Actual Quantity | WorkOrderActualQuantity | Read Only | Actual quantity corresponding to the Work Order object. |
| Work Order Scheduled Quantity | WorkOrderScheduledQuantity | Read Only | Quantity scheduled for the Work Order object. |
| Work Order Remaining Quantity | WorkOrderRemainingQuantity | Read Only | Quantity of material remaining for the work order. |
| Work Order Closed Date | WorkOrderClosedDate | Read/Write | Closed date assigned to the Work Order object. |
| Work Order Due Date | WorkOrderDueDate | Read/Write | Due date assigned to the Work Order object. |
| Work Order Closed | WorkOrderClosed | Read/Write | The boolean assigned to closed property of the Work Order object. |

### Object Functions

This object provides the following functions:

* [getActiveOperationsResponses()](/articles/user-manual/mes-work-order/a/h4__80649587)
* [getActualMaterialLots(beginDate, endDate, lotUseType)](/articles/user-manual/mes-work-order/a/h4_1167254018)
* [getActualPersonnel(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4_1591175675)
* [getActualQuantity()](/articles/user-manual/mes-work-order/a/h4__2098013238)
* [getActualSupplementalEquipment(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4_1699588839)
* [getClosedDate()](/articles/user-manual/mes-work-order/a/h4__1141591755)
* [getDueDate()](/articles/user-manual/mes-work-order/a/h4_2145490167)
* [getMaterialRef()](/articles/user-manual/mes-work-order/a/h4__569210707)
* [getMaterialRefName()](/articles/user-manual/mes-work-order/a/h4__986599752)
* [getMaterialRefType()](/articles/user-manual/mes-work-order/a/h4__1830630347)
* [getMaterialRefUUID()](/articles/user-manual/mes-work-order/a/h4__599406076)
* [getOperationsRequests()](/articles/user-manual/mes-work-order/a/h4_1186028499)
* [getOperationsRequests(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4__1837112989)
* [getOperationsResponses()](/articles/user-manual/mes-work-order/a/h4_393433249)
* [getOperationsResponses(beginDate, endDate)](/articles/user-manual/mes-work-order/a/h4__2109659807)
* [getRemainingQuantity()](/articles/user-manual/mes-work-order/a/h4_1432535084)
* [getScheduledQuantity()](/articles/user-manual/mes-work-order/a/h4__1130228479)
* [getWorkOrderQuantity()](/articles/user-manual/mes-work-order/a/h4_1755886227)
* [isClosed()](/articles/user-manual/mes-work-order/a/h4__2140618815)
* [setClosed(closed)](/articles/user-manual/mes-work-order/a/h4_125988475)
* [setClosedDate(closedDate)](/articles/user-manual/mes-work-order/a/h4__2028550541)
* [setDueDate(dueDate)](/articles/user-manual/mes-work-order/a/h4__1226248445)
* [setMaterialRef(mesMaterialDef)](/articles/user-manual/mes-work-order/a/h4_77700932)
* [setMaterialRef(materialLink)](/articles/user-manual/mes-work-order/a/h4_1160383467)
* [setWorkOrderQuantity(quantity)](/articles/user-manual/mes-work-order/a/h4_1754314632)
* [updateQuantities()](/articles/user-manual/mes-work-order/a/h4_643090573)

* * *
 
#### getActiveOperationsResponses()
 
##### Syntax 

getActiveOperationsResponses()

* Parameters

None

* Returns

MESList&lt;[MESObjectLink](/articles/user-manual/mes-object-link)&gt; Returns actively running Operations Responses that are associated with a work order.

* Scope

All

#### getActualMaterialLots(beginDate, endDate, lotUseType) 
 
Gets the Material Lots related to this Work Order, filtered by begin and end dates and Lot Use Type.

##### Syntax

getActualMaterialLots(beginDate, endDate, lotUseType)

* Parameters

Date **beginDate** - Date (inclusive) when the Operations Request for this Work Order was executed. Pass in 'None' to use the default date [1 Jan, 1970 00:00:00].

Date **endDate** - Date (inclusive) when the Operations Request for this Work Order finished executing. Pass in 'None' to use the default date [1 Jan, 2200 00:00:00].

String **lotUseType** - The lot's use-type. Valid uses are: 'In', 'Out', 'Consumable', and 'By-product'.

* Returns

MESList&lt;[MESObjectLink](/articles/user-manual/mes-object-link)&gt; **matLotLinks** - A list of MESObjectLinks that each have a reference to an [Material Lot](/articles/user-manual/material-lot) object.

* Scope

All

#### getActualPersonnel(beginDate, endDate) 
 
Gets the Personnel related to this Work Order, filtered by begin and end dates.

##### Syntax 

getActualPersonnel(beginDate, endDate)

* Parameters

Date **beginDate** - Date (inclusive) when the Operations Request for this Work Order was executed. Pass in 'None' to use the default date [1 Jan, 1970 00:00:00].
 
Date **endDate** - Date (inclusive) when the Operations Request for this Work Order finished executing. Pass in 'None' to use the default date [1 Jan, 2200 00:00:00].

* Returns

MESList&lt;[MESObjectLink](/articles/user-manual/mes-object-link)&gt; **personLinks** - A list of MESObjectLinks that each have a reference to a [personnel object](/articles/user-manual/personnel-objects).

* Scope

All

#### getActualQuantity() 
 
Gets the actual work order quantity.

##### Syntax 
 
getActualQuantity()

* Parameters

None

* Returns

Double **quantity** - The work order quantity.

* Scope

All

#### getActualSupplementalEquipment(beginDate, endDate) 
 
Gets the Supplemental Equipment related to this Work Order, filtered by begin and end dates.
 
#####  

##### Syntax 
 
getActualSupplementalEquipment(beginDate, endDate)

* Parameters

Date **beginDate** - Date (inclusive) when the Operations Request for this Work Order was executed. Pass in 'None' to use the default date [1 Jan, 1970 00:00:00].
 
Date **endDate** - Date (inclusive) when the Operations Request for this Work Order finished executing. Pass in 'None' to use the default date [1 Jan, 2200 00:00:00].

* Returns

MESList&lt;[MESObjectLink](/articles/user-manual/mes-object-link)&gt; supEqpLinks - A list of MESObjectLinks that each have a reference to a supplemental equipment object.

* Scope

All

#### getClosedDate() 
 
Gets the closed date for the work order.

##### Syntax 

getClosedDate()

* Parameters

None

* Returns

Date **closedDate** - Closed date for the work order.

* Scope

All
 
#####  

##### Code Example 
 
```python
woObj = system.mes.workorder.getMESWorkOrder('A34')
                        
closedDate = woObj.getClosedDate()
                        
print closedDate
```


####  getDueDate() 
 
Gets the due date for the work order.

##### Syntax 
 
**getDueDate()**

* Parameters

None

* Returns

Date **dueDate** - Due date for the work order.

* Scope

All

##### Code Example 
 
```python
woObj = system.mes.workorder.getMESWorkOrder('A34')
                        
endDate = woObj.getDueDate()
                        
print endDate
```


####  getMaterialRef() 
 
Gets the material definition object corresponding to the work order.

##### Syntax 
 
getMaterialRef()

* Parameters

None

* Returns

[MESObjectLink](/articles/user-manual/mes-object-link) **mesMaterialDef** - [Material definition object](/articles/user-manual/material-objects/a/MaterialObjects-MaterialDef) corresponding to the work order.

* Scope

All

#### getMaterialRefName() 
 
Gets the name of the material reference object.

##### Syntax 
 
**getMaterialRefName()**

* Parameters

None

* Returns

String **materialRefName** - Name of the [material reference object](/articles/user-manual/mes-material-ref-property).

* Scope

All

#### getMaterialRefType() 
 
Gets the type of the material reference object.

##### Syntax 

getMaterialRefType()

* Parameters

None

* Returns

String **materialRefType** - Type of the [material reference object](/articles/user-manual/mes-material-ref-property).

* Scope

All

#### getMaterialRefUUID() 
 
Gets the UUID of the material reference object.

Syntax

getMaterialRefUUID()

* Parameters

None

* Returns

String **materialRefUUID** - Unique identifier that represent the [material reference object](/articles/user-manual/mes-material-ref-property).

* Scope

All

####   getOperationsRequests() 
 
Gets the Operations Requests related to this Work Order.

#####  Syntax 
 
getOperationsRequests()

* Parameters

None

* Returns

[MESList](/articles/user-manual/mes-list)&lt;MESObjectLink&gt; **opsReqLinks** - A list of [MESObjectLink](/articles/user-manual/mes-object-link)s that each have a reference to an [MESOperationsRequest](/articles/user-manual/request-objects)object.

* Scope

All

#### getOperationsRequests(beginDate, endDate) 
 
Gets the Operations Requests related to this Work Order, filtered by begin and end dates.

##### Syntax 
 
getOperationsRequests(beginDate, endDate)

* Parameters

Date **beginDate** - Date (inclusive) when the Operations Request for this Work Order was executed. Pass in 'None' to use the default date [1 Jan, 1970 00:00:00].
 
Date **endDate** - Date (inclusive) when the Operations Request for this Work Order finished executing. Pass in 'None' to use the default date [1 Jan, 2200 00:00:00].

* Returns

[MESList](/articles/user-manual/mes-list)&lt;MESObjectLink&gt; **opsReqLinks** - A list of [MESObjectLink](/articles/user-manual/mes-object-link)s that each have a reference to an [MESOperationsRequest](/articles/user-manual/request-objects) object.

* Scope

All

#### getOperationsResponses() 
 
Gets the Operations Responses related to this Work Order.

##### Syntax 
 
getOperationsResponses()

* Parameters

None

* Returns

[MESList](/articles/user-manual/mes-list)&lt;MESObjectLink&gt; **opsRspLinks** - A list of [MESObjectLink](/articles/user-manual/mes-object-link)s that each have a reference to an [MESOperationsRequest](/articles/user-manual/request-objects) object.

* Scope

All

#### getOperationsResponses(beginDate, endDate) 
 
Gets the Operations Responses related to this Work Order, filtered by begin and end dates.

##### Syntax 

getOperationsRequests(beginDate, endDate)

* Parameters

Date **beginDate** - Date (inclusive) when the Operations Request for this Work Order was executed. Pass in 'None' to use the default date [1 Jan, 1970 00:00:00].
 
Date **endDate** - Date (inclusive) when the Operations Request for this Work Order finished executing. Pass in 'None' to use the default date [1 Jan, 2200 00:00:00].

* Returns

[MESList](/articles/user-manual/mes-list)&lt;MESObjectLink&gt; **opsRspLinks** - A list of [MESObjectLink](/articles/user-manual/mes-object-link)s that each have a reference to an [MESOperationsRequest](/articles/user-manual/request-objects) object.

* Scope

All

#### getRemainingQuantity() 
 
Gets the remaining quantity of the work order.

Syntax

getRemainingQuantity()

* Parameters

None

* Returns

double **qty** - Remaining quantity for the work order.

* Scope

All

#### getScheduledQuantity() 
 
Gets the scheduled quantity of the work order.

##### Syntax 
 
getScheduledQuantity()

* Parameters

None

* Returns

double **quantity** - The scheduled quantity of work order.

* Scope

All

#### getWorkOrderQuantity() 
 
Gets the quantity assigned for the work order.

##### Syntax 
 
getWorkOrderQuantity()

* Parameters

None

* Returns

double quantity - The quantity assigned for work order.

* Scope

All

#### isClosed() 
 
Checks whether the work order is closed.

##### Syntax 

isClosed()

* Parameters

None

* Returns

boolean True if it is a closed work order and False otherwise.

* Scope

All

#### setClosed(closed) 
 
Sets the work order to closed.

##### Syntax 
 
setClosed(closed)

* Parameters

boolean **closed** - Set to True to set work order to close and False otherwise.

* Returns

Nothing

* Scope

All

#### setClosedDate(closedDate) 
 
Sets the closed date for the work order.

##### Syntax 
 
setClosedDate(closedDate)

* Parameters

Date **closedDate** - Closed date for the work order.

* Returns

None

* Scope

All
 
#####  

##### Code Example 
 
```python
# closes a work order, and sets the closed date to yesterday at the current time
                            
workOrder = system.mes.workorder.getMESWorkOrder("My Work Order")
                            
workOrder.setClosed(True)
                            
closedDate = system.date.addDays(system.date.now(), -1)
                            
workOrder.setClosedDate(closedDate)
                            
system.mes.saveMESObject(workOrder)
```


####  setDueDate(dueDate) 
 
Sets the due date for the work order.

##### Syntax 
 
setDueDate(dueDate)

* Parameters

Date **dueDate** - Due date to set for the work order.

* Returns

Nothing

* Scope

All

#### setMaterialRef(mesMaterialDef) 
 
Sets the material definition as a reference for the work order.
 
##### Syntax 
 
**setMaterialRef(mesMaterialDef)**

* Parameters

MESMaterialDef **mesMaterialDef** - Material definition to set as the reference for the work order.

* Returns

Nothing

* Scope

All

#### setMaterialRef(materialLink) 
 
Sets the material reference for the work order.
 
##### Syntax 
 
setMaterialRef(materialLink)

* Parameters

MESObjectLink **materialLink**- Material reference to set for the work order.

* Returns

Nothing

* Scope

All

#### setWorkOrderQuantity(quantity) 
 
Sets the quantity for the work order.

##### Syntax 
 
setWorkOrderQuantity(quantity)

* Parameters

double quantity - Quantity to set for the work order.

* Returns

Nothing

* Scope

All

#### updateQuantities() 
 
This method queries the system and updates all of the quantities (work order quantity, actual quantity, scheduled quantity, remaining quantity) for the work order object.

##### Syntax 
 
updateQuantities()

* Parameters

None

* Returns

Nothing

* Scope

All

This object inherits the [AbstractMESObject functions](/articles/user-manual/abstractmesobject-functions).
 
### Object Events 
 
Objects have events associated with them that allow for custom scripts to be added whenever the event occurs. Refer to [MES Object Events](https://help.sepasoft.com/docs/display/SEPA/MES+Object+Events) for more information.
 
This object inherits the [AbstractMESObject events](/articles/user-manual/events).

**Sepasoft MES Module Suite**