Hi,
I create a datasource from a dataset. Then I create a relation with solution model from a table to this datasource. In a modal dialog I create records through the relation. Here is my problem.
If the program isn’t in a transaction (autosave=true) when the dialog is closed I have all the created records in the dataset, that’s ok. But when the program is in a transaction (autosave = false) I haven´t the records in the dataset until the transaction ends (and autosave = true).
Is there any function to force the save to the dataset?
I tried to use databaseManager.saveData([record]) but it returns false.
Hi Victor,
saveDate() should work. Perhaps something obvious but are you using this exact syntax databaseManager.saveData([record]) ?
If so then that is wrong. The [record] is an optional parameter. Just use databaseManager.saveData() to save any unsaved data.
Hope this helps.
Hi Robert,
victor.rojo:
databaseManager.saveData([record])
hehe, a quickly copy-paste of the servoy sample.
I tried databaseManager.saveData(foundset[relationName].getRecord(1)) and always return false (before close the modal dialog when there isn´t transaction and after close it in a transaction)
Hi Victor,
Does foundset[relationName].getRecord(1) indeed return a JSRecord object ?
ROCLASI:
Hi Victor,Does foundset[relationName].getRecord(1) indeed return a JSRecord object ?
Yes
=>foundset[relationName].getRecord(1)
Record {_sv_rowid:DbIdentValue1564054973,pickcolumid:10,selected:1}
Have you already checked the reason why the save fails?
databaseManager.getFailedRecords() and then look at the exception property on the record
Paul
pbakker:
Have you already checked the reason why the save fails?databaseManager.getFailedRecords() and then look at the exception property on the record
Paul
Yes… and doesn´t return anything
Victor,
When you want to save the related records in the dataset, is the main (regular db record) already saved?
From what you showed it seems that this is a dbident table and if the record has not been saved yet you cannot save related records with that fk.
A dbident value only gets known when the record is saved, until then in memory there is a placeholder (DbIdentValue1564054973).
Rob
rgansevles:
When you want to save the related records in the dataset, is the main (regular db record) already saved?
Yes.
rgansevles:
From what you showed it seems that this is a dbident table and if the record has not been saved yet you cannot save related records with that fk.
A dbident value only gets known when the record is saved, until then in memory there is a placeholder (DbIdentValue1564054973).
The _sv_rowid field of the record is only in the foundset not in the dataset. Its created by Servoy when a foundset is created from a dataset.
But I find the problem… I was testing it from the Interactive Console where the saveData() returns false… (also with records from a table)
If I try it running the solution the record is saved to the dataset.
Another question, databaseManager.convertFoundSet(foundset,relation) should work?
victor.rojo:
I was testing it from the Interactive Console where the saveData() returns false… (also with records from a table)
If I try it running the solution the record is saved to the dataset.
There is a problem with saving data from the debugger, something with saving from another thread than from the app.
This is fixed in Servoy 6.
victor.rojo:
Another question, databaseManager.convertFoundSet(foundset,relation) should work?
This function only works with relations within 1 server (because the 2 tables in the relation are joined in sql).
A relation from a real table to an in-memory table is across 2 ‘servers’ and therefore this is not possible.
It is possible with a relation between 2 in-memory tables, they are on the same ‘server’.
Rob
Ok,
Thanks Rob.