If we want to write data back to the API (inserts/updates/deletes), we need to create what's called a delta dataset. The delta dataset represents the changes we want to make to the underlying data.
The format of the delta dataset is similar to the normal dataset we get back when calling the load method, with a few changes.
First of all, for each record, we need an action code. The action code can be insert, update, delete, or none. An action code of none is used to indicate which child records to update; no updates will be done to the table itself. When using none, you only need to specify the fields that are part of the primary key for the table, although you can specify all fields if you'd like. For example, if we want to make changes to booking 1 which is part of invoice 1, we would create a delta dataset like this:
"DELTADATASET":{
"Invoice":[
{
"NONE":{
"InvoiceNo":1,
"Booking":[
{
"NONE":{
"BookingNo":1
}
}
]
}
}
]
}
Now we can add the insert action for the UDID table below the booking table:
"UDID":[
{
"INSERT":{
"UDIDNo":5,
"Booking_LinkNo":1,
"Invoice_LinkNo":1,
"UDID":"test5555"
}
}
]
So we end up with this:
"DELTADATASET":{
"Invoice":[
{
"NONE":{
"InvoiceNo":1,
"Booking":[
{
"NONE":{
"BookingNo":1,
"UDID":[
{
"INSERT":{
"UDIDNo":5,
"Booking_LinkNo":1,
"Invoice_LinkNo":1,
"UDID":"test5555"
}
}
]
}
}
]
}
}
]
}
(also see attached InsertUDID.JSON)
The above JSON tells the API to insert a UDID record with UDID number of 5 and a value of "test5555" into booking 1 which is part of invoice 1.
We would then make the call to Invoice.ApplyUpdates and pass in our session ID, and the delta dataset.
Dan