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:
ServiceOrderNbrAppointmentRecords > Service Order Nbr.ServiceOrderTypeAppointmentRecords > Service Order TypeCustomerAppointmentRecords > 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:
- AppointmentNbr AppointmentRecords > Customer
- ServiceOrderLocation Service Order Header > Location > LocationID (This was set up as a failed attempt to fix the bug)
- Actual Dates and Times Settings > Appointment Times > Actual Date And Time
- Scheduled Dates and Times Service Order Header > Delivery Notes
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
ServiceOrderNbrandBranch, even though you'd expect the system to work with just the Appointment Number...Learnings