|
Http Verb |
POST |
|---|---|
|
Url |
/work-orders/r1/work-cycles/{workCycleId}/work-orders |
|
Permissions required |
WO Configuration: Edit (fsm.core.workorder.configuration.edit) |
|
Personally Identifiable Information (PII) |
No |
|
Sensitive Information |
No |
|
Last Modified Version |
r1 |
|
Released since |
2024 W3 (FSM 18.0) |
|
Deprecated since |
|
|
Removed since |
|
|
Tech Tags |
|
Business Logic
This API is responsible for creating a new work order and its operations based on a work cycle and its structures.
Automatic Code Calculation
-
If the
codefield is not provided by the client, it will be automatically calculated by the business logic. -
If the
operationCenterIdis not provided in the request payload, the request fieldcodewill be ignored, and it will be necessary to call the API POST /work-orders/r1/work-orders/unique-codes to generate the work order code.
Work Order Activation
-
If the field
activateWorkOrderisnullorfalse, the work order will be created in the "DRAFT" state. It will be possible to activate it later by calling the API POST /work-orders/r1/work-orders/{workOrderId}/activations. -
If
activateWorkOrderistrue, the work order status will be set to either "OPEN" or "RELEASE".
Filtering and Searching Work Orders
-
The
idreturned in the response payload, or theworkCycleIdprovided as input, can be used to filter and search for the created work order using the standard API GET /work-orders/r1/work-orders .
Work Order Creation
-
Extract Work Cycle
-
Extract the
workCyclerecord related toworkCycle.id = {workCycleId}.
-
-
Visibility Check
-
If
workCycle.visibleisfalse, return error WORKORDERS_032.
-
-
Work Order Type Check
-
Get
workCycle.workOrderTypeIdand check if it exists andworkCycle.workOrderTypeId.activeistrue. If not, return error WORKORDERS_031.-
Set
workOrder.typeId = workCycle.workOrderTypeId.
-
-
-
Assign Work Cycle Id
-
Set
workOrder.workCycleId = workCycle.id.
-
-
Operations Assignment
-
If
workCycle.operationsAssignment = "AGGREGATE":-
Set
workOrder.aggregatedDuration = workCycle.workOrderDuration. -
Set
workOrder.aggregatedResidualDuration = workCycle.workOrderDuration. -
Set
workOrder.aggregatedCardinalityId = workCycle.teamCardinalityId. -
Set
workOrder.state = "DRAFT".
-
-
-
Set Remaining Fields
-
Populate the remaining fields from the input request body.
-
Work Order Operations Creation
-
Extract Work Cycle Structure
-
Extract the
workCycleStructurerecords whereworkCycleStructure.workCycleId = {workCycleId}. If no record is found, it will not create any work order operation.
-
-
Process Each Work Cycle Structure
-
Ignore records where
workCycleStructure.optionalOperation = true. -
If
workCycleStructure.workOrderOperationTypeId.active != true, return error WORKORDERS_033. -
Set
workOrderOperation.workOrderOperationTypeId = workCycleStructure.workOrderOperationTypeId.
-
-
Aggregated Operations Assignment
-
If
workCycle.operationsAssignment = "AGGREGATE":-
Set
workOrderOperation.teamCardinalityId = workCycleStructure.teamCardinalityId. -
Set
workOrderOperation.defaultDuration = workCycleStructure.defaultDuration. -
Set
workOrderOperation.currentDuration = workCycleStructure.defaultDuration.
-
-
-
Activity Assignment
-
Search in
workOrderOperationTypeActivityfiltering byworkOrder.workOrderTypeId,workOrderOperation.workOrderOperationTypeId, andactive = true. -
Get the first record and set
workOrderOperation.activity = workOrderOperationTypeActivity.id. -
If no record is found, get the value from system settings.
-
-
Technical Object Check
-
If
workCycleStructure.workOrderOperationTypeId.technicalObjectTypeIdisnull, getworkCycle.workOrderType.technicalObjectTypeId. Otherwise, getworkCycleStructure.workOrderOperationTypeId.technicalObjectTypeId. -
Check if
technicalObjectTypeIdis an "ASSET" or an "ACCOUNT". -
If
technicalObjectTypeIdis "ASSET", andworkCycleStructure.repeatable = true, create repeatable work order operations. Otherwise, create a single work order operation.
-
Repeatable Work Order Operations Creation
-
Asset Retrieval
-
Use the
technicalObjectTypeIdandworkCycleStructure.assetStatusto retrieve and filter the list of assets related to the one passed in input through itsaddressIdwith the accepted status. -
The field
workCycleStructure.assetStatuscan be populated through the API PATCH /work-orders/r1/work-cycles/{workCycleId}/structures/{workCycleStructureId}/repeatable-operation-filters.-
For each asset retrieved, create a new work order operation record with previously set values.
-
-
-
Populate Fields for Each Asset
-
Set
workOrderOperation.address = asset.addressId. -
Set
workOrderOperation.typeId = workCycleStructure.workOrderOperationTypeId. -
Set
workOrderOperation.workCycleStructureId = workCycleStructure.id. -
Calculate the order field based on the previous
workOrderOperationcreated for thisworkOrderId, or setworkOrderOperation.order = workCycleStructure.order.
-
Single Work Order Operation Creation
-
Address Assignment
-
Set
workOrderOperation.address = workOrder.addressId.
-
-
Technical Object Assignment
-
Set
workOrderOperation.typeId = workCycleStructure.workOrderOperationTypeId.
-
-
Work Cycle Structure Assignment
-
Set
workOrderOperation.workCycleStructureId = workCycleStructure.id.
-
-
Order Field Calculation
-
Calculate the order field based on the previous
workOrderOperationcreated for thisworkOrderId, or setworkOrderOperation.order = workCycleStructure.order.
-
Verification of Maximum Work Order Operations to be Created
-
Retrieve the number of work order operations to be created.
-
Check if this number is less than or equal to the value specified in the company properties
company.fsm.workorder.maxOperationWorkCycleCreation. Default value formaxOperationWorkCycleCreationis50. -
If the number exceeds the specified value, return the error code WORKORDERS_038.
Work Order Activation
If activateWorkOrder = true:
-
Check if with workOrder creation, at least one workOrderOperation has been created with it:
-
If yes:
-
Calculate the work order state to set it to
"OPEN"or"SCHEDULABLE". -
Calculate the work order operation state to set it to
"OPEN"or"SCHEDULABLE".
-
-
If not:
-
Return error WORKORDERS_002.
-
-
Path Parameters
|
Field |
Note |
|---|---|
|
workCycleId |
|
Header Parameters
Default.
Request Body Parameters
|
Field |
Validations |
Note |
|---|---|---|
|
addressId |
|
|
|
startDate |
Format: ISO-8601 |
|
|
endDate |
Format: ISO-8601 |
|
|
operationCenterId |
|
|
|
description |
Max Length: 80 |
|
|
externalCode |
Max Length: 40 |
|
|
code |
|
If not passed by the client, will be calculated automatically by the business logic. operationCenterId should be not null If operationCenterId = null → the request field will be ignored |
|
externalSystemId |
|
|
|
notes |
Max Length: 4000 |
|
|
urgencyId |
Referenced resource id existance check |
|
|
workCenterId |
|
|
|
appointmentStartDate |
Format: ISO-8601 |
|
|
appointmentEndDate |
Format: ISO-8601 |
|
|
activateWorkOrder |
|
|
Response documentation
Response payload fields
|
Field |
Note |
|---|---|
|
id |
|
Response error codes
NOT_FOUND, BASE_0001, BASE_0010, BASE_0011, BASE_0003, WORKORDERS_006, WORKORDERS_010, WORKORDERS_031, WORKORDERS_032, WORKORDERS_033, WORKORDERS_038