Hi all.
Is there any difference between databaseManager.saveData() and databaseManager.saveData(foundset)?
I mean the way Servoy save the data …
Thanks in advance.
Hi all.
Is there any difference between databaseManager.saveData() and databaseManager.saveData(foundset)?
I mean the way Servoy save the data …
Thanks in advance.
Hi Roberto,
databaseManager.saveData() saves all data of all foundsets.
databaseManager.saveData(foundset) only saves the data in the specified foundset
databaseManager.saveData(record) only saves the data in the specified record
Thanks a lot omar for your answer, but my question was because of a strange behavior of my solution.
I use this function to insert a new document entity on my database
function new_doc(type){
/** @type {JSFile} */
var jsfile = plugins.file.showFileOpenDialog(1,null,false);
/** @type {JSFoundset <db:/my_server/t100_documents>} */
var fs_doc = databaseManager.getFoundSet("my_server","t100_documents");
fs_doc.newRecord();
fs_doc.name = file.getName();
fs_doc.doc_insert_date = application.getServerTimeStamp();
fs_doc.doc_save_date = application.getServerTimeStamp();
fs_doc.document_type = type;
fs_doc.data = jsfile.getBytes();
fs_doc.md5 = plugins.Utilidades.MD5File(file.getAbsolutePath());
databaseManager.saveData(fs_doc);
}
table t100_documents has a calculation
function calc_entity{
return "DOC" + id
}
with databaseManager.saveData();
the calculation value is as expected, “DOC27”, where 27 is the id field
with databaseManager.saveData(fs_doc);
the calculation value is “DOCDbIdentValue31124” … but if the user interacts with any component of the form ( i.e., change a tab in a tabpanel inside the form) the field gets the excpected value “DOC27”
Thanks in advance. Roberto Blasco.
Then the simple advice would be to use databaseManager.saveData() but I can understand you want to know why. Seems like a plausible case for a bug report?
Hi omar
I can’t do saveData() because the form from where I use the function has another datasource in “edit” mode.
Anyway, this behavior is on developer mode. I’m gonna try it on the server to check it.
Best regards. Roberto Blasco
I forgot it … I’m using servoy v.6.0.6 with MySQL in a Windows 7 System.
I’ve found the cause of this strange behaviour !!!
It’s related with the post
Thank for all
this code:
function calc_entity{
return "DOC" + id
}
is a bit weird if the id is a dbident value
Because then the calc doesn’t work right away, because there is no value yet, the value is only there after you save it
So what should it really return before you save a new record?
Thanks jcompagner
I’ve move the code to an “afterRecordInsert” event
Best regards. Roberto Blasco.