NextGen APIs

POST /work-orders/execution/r1/interventions/{interventionId}/intervention-start

Http Verb

POST

Url

/work-orders/execution/r1/interventions/{interventionId}/intervention-start

Permissions required


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

PAGINATION ORDERING-SERVER-SIDE

Business Logic

This API sets the start date of a work order operation using its intervention Id.

The start date must be set after the arrival on site of the intervention. You can set the arrival on site date of the intervention using this API: POST /work-orders/execution/r1/interventions/{interventionId}/arrival-on-site.

In a team scenario, assistants follow the same rules as the foreman, but their intervention information is linked to the foreman's intervention.

The result of this API call can be viewed by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId}and passing the intervention Id as the outcome Id in the path parameter.

It is possible to skip this step in the intervention process and directly call the following API POST /work-orders/execution/r1/interventions/{interventionId}/outcomes

Steps

Retrieve Intervention

We will refer to interventionFromInputId as the intervention record with intervention.id equal to interventionId provided in the path parameter of this API.

Example:

  • interventionFromInputId.statusId will be the statusId field of the intervention with id equal to interventionId.

  • interventionFromInputId.outcome will be the Intervention outcome of the intervention with id equal to interventionId, that can be retrieved by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId} .

  1. Validate Intervention Status

    • Check if interventionFromInputId.statusId is ‘IN_EXECUTION’.

    • Check if interventionFromInputId.workOrderOperationId is null.

    • Check if Core System Setting field "Outcome Minimum Date" < interventionStartDate:

    • Check if interventionStartDate < Date.now() + 1 (it should be at most a date in the present, not in the future):

    • Check if workOrderHeader.isWoByOrder())

      • If TRUE ->operation.getParentOperation() != null → you can take in charge an intervention only if it is the one of the parent operation

      • if not return the error EXECUTION_005.

  2. Handle Existing Interventions

    • Search for all intervention records associated with the same resource with statusId values ‘IN_CHARGE' or 'IN_EXECUTION’ and workOrderOperationId not equal to interventionFromInputId.workOrderOperationId

    • We will refer to this list of intervention records as interventionsToBeDeleted.

    • For each intervention in the interventionsToBeDeleted list:

      • Set intervention.arrivalDate to null

      • Set intervention.takeInChargeDate to null

      • Set intervention.startDate to null

      • Change intervention.statusId to ‘SUBMITTED’ by passing the ‘SUBMIT’ action.

      • Update intervention.workOrderOperationId.statusId

      • Update intervention.workOrderOperationId.workOrderId.statusId

      • Retrieve all records of resourceAccountedHourentity with resourceAccountedHour.interventionId equal to intervention.id and resourceAccountedHour.outcomeEndDate equal to null.

        • For each record, set:

          • resourceAccountedHour.takeInCharge to null

          • resourceAccountedHour.arrivalDate to null

          • resourceAccountedHour.outcomeStartDate to null

  3. Take In Charge the Intervention

    • If interventionFromInputId.outcome.startDate is null:

      • Set interventionFromInputId.outcome.startDate = interventionStartDate

    • If interventionFromInputId.outcome.arrivalDate is null:

      • Set interventionFromInputId.outcome.arrivalDate = interventionStartDate

    • If interventionFromInputId.outcome.takeInChangeDate is null:

      • Set interventionFromInputId.outcome.takeInChangeDate = interventionStartDate

    • If company.fsm.accounting.emptyAgendaResourceDeletion property is enabled, remove all empty resourceAccountedHour associated with the same interventionFromInputId, they will be removed if resourceAccountedHour.spentTime, resourceAccountedHour.takeInChargeDate are null and if resourceAccountedHour.resource is different from the resource associated with the interventionFromInputId

    • Update interventionFromInputId.workOrderOperationId.statusId

    • Update interventionFromInputId.workOrderOperationId.workOrderId.statusId

Header Parameters

Default.

Request Body Parameters

Field

Validations

Note

interventionStartDate



Response documentation

Response payload fields

Response error codes

NOT_FOUND, BASE_0001, BASE_0003, BASE_0010, BASE_0011, WORKORDERS_ORCHESTRATOR_006, EXECUTION_002, EXECUTION_003, BASE_0016.