I am saving a record from the current foundset but the changes are not saved in the database:
var _siteRecord = foundset.getRecord(foundset.getSelectedIndex());
databaseManager.saveData(_siteRecord);
I inspected _siteRecord, it returns the record with the expected changes done by the user.
The save command returns true. However nothing changes in the database.
What could this be?
In another scenario, databaseManager.saveData(_record) returns false but .getFailedRecords() returns an empty array.
Why would this happen?
jcompagner:
if you cal databaseManager.getEditedRecords() right before you call save
is that record that you try to save next in that array?
The problem came up again.
I check the edited records and can see the record that has been edited with all appropriate changes.
The form that the record is created in was modified before that: the datasource was changed to another table, but everything seems ok, the form data reflect whatever is in the database table, deleteRecord() works fine on the same form…
First, the result of databaseManager.saveData() returns a non predictable result
Second, the saveData does not save the data into the DB
I also figured out that I better ignore the result of the saveData(). I check for databaseManager.getFailedRecords() to check if a save was successful. This works fine for us.
If a save fails I ckeck:
Is the primary key filled out and unique?
do I have a constraints on the table in the DB which prevents a save?
is there a table event in Servoy (onRecordUpdate or onRecordInsert) preventing a save?
var before = databaseManager.getEditedRecords();
// does before really have the right changed values…
var saved = databaseManagger.saveData();
var after= databaseManager.getEditedRecords();
var failed= databaseManager.getFailedRecords();
By the way databaseManager.saveData() can return false without failedReccords giving results
if the validation does fail in servoy (onDataChange events or table events) then it will just return false.