I have two related tables. This is a relationship where parent can have zero or many notes. I am trying to save a note that's related to original record. Code itself is
app.datasources.RadiosManualSave.load(function() {
...
var existingRecord = app.datasources.RadiosManualSave.item;
... // update some fields of the existingRecord & save later
try {
app.datasources.RadiosManualSave.saveChanges(function() {
var notesCreate = app.datasources.RadioNotes.modes.create ;
var newNote = notesCreate.item ;
newNote.Notes = tempRecord.Notes ;
//newNote.Radios_fk = existingRecord.Id ;
newNote.Radios = existingRecord ;
notesCreate.createItem(function() {
app.showPage(app.pages.Radios);
});
});
} catch(e) {
showSnackbar('Error saving record');
app.datasources.RadiosManualSave.clearChanges();
}
...
}
The code fails when I associate the note with the existing record.
The error message is:
Can't associate draft record with record in draft datasource.
However existing record is not in draft datasource and is already in the table. Assigning to the foreign key works without problems.