Acumatica API / Appointments / LocationID cannot be empty

20 views Asked by At

Question

Where is LocationID field we see in our error message, and how can we stop it being empty?

Overview

Our system attempts to create Appointments for Service Orders via the Acumatica (branded as MYOB Advanced) API. We are having a lot of trouble with the error:

'LocationID' cannot be empty.; LocationID: 'LocationID' cannot be empty.

This error occurs in the API only, we do not see the error when creating appointments using the UI.

The API tries to take an existing Service Order, add an Appointment for it, and then set the Scheduled and Actual dates/times on the new appointment. The ultimate goal is to enter an appointment log and create time cards automatically. The error occurs when we try and set the dates and times.

Technical Detail

The working request to create the appointment looks like:

{
  "ServiceOrderNbr": {
    "value": "40054"
  },
  "ServiceOrderType": {
    "value": "TECH"
  },
  "BranchLocation": {
    "value": "DVM"
  },
  "Customer": {
    "value": "CSOUTHPAC"
  }
}

Which is mapped to the following fields in our custom endpoint:

  1. ServiceOrderNbr AppointmentRecords > Service Order Nbr.
  2. ServiceOrderType AppointmentRecords > Service Order Type
  3. Customer AppointmentRecords > Customer

The failing request to set the dates and times looks like :

{
  "AppointmentNbr": {
    "value": "40083-4"
  },
  "ServiceOrderLocation": {
    "value": "MAIN"
  },
  "ScheduledStartDate": {
    "value": "2024-03-06T00:00:00.000Z"
  },
  "ScheduledEndDate": {
    "value": "2024-03-06T00:06:00.000Z"
  },
  "ActualStartDate": {
    "value": "2024-03-06T00:00:00.000Z"
  },
  "ActualEndDate": {
    "value": "2024-03-06T00:06:00.000Z"
  },
  "ScheduledStartTime": {
    "value": "2024-03-06T00:00:00.000Z"
  },
  "ScheduledEndTime": {
    "value": "2024-03-06T00:06:00.000Z"
  },
  "ActualStartTime": {
    "value": "2024-03-06T00:00:00.000Z"
  },
  "ActualEndTime": {
    "value": "2024-03-06T00:06:00.000Z"
  }
}

Which is mapped to the following fields in our custom endpoint:

  1. AppointmentNbr AppointmentRecords > Customer
  2. ServiceOrderLocation Service Order Header > Location > LocationID (This was set up as a failed attempt to fix the bug)
  3. Actual Dates and Times Settings > Appointment Times > Actual Date And Time
  4. Scheduled Dates and Times Service Order Header > Delivery Notes
1

There are 1 answers

0
Sparklellama On

Solution

As per usual, solution was found just after posting. All Acumatica API queries must contain all key fields for the record you are updating, or they fail in weird ways.

In this case, the request started working when we included ServiceOrderNbr and Branch, even though you'd expect the system to work with just the Appointment Number...

{
  "AppointmentNbr": {
    "value": "40083-4"
  },
  "ServiceOrderNbr": {
    "value": "40083"
  },
  "Branch": {
    "value": "DVMM"
  },
...

Learnings

  • Error messages from Acumatica can be very misleading.
  • Make sure you always include key fields is requests.