In my form I am having UI elements to enter data and a Submit button. In onShow() event i have set databaseManager.setAutoSave(false), but when I execute form in brower adds a new empty record in table(pk is auto incremental) which should not, only on submit event should add data in table. I don’t know why databaseManager.setAutoSave(false) on onShow() is not working properly or might I have missed something else.
databaseManager.setAutoSave(false) returns a boolean, what is the outcome of that?
A reason why databaseManager.setAutoSave(false) will fail is when there are unsaved changes which can’t be written to the DB.
hardina09,
databaseManager.setAutoSave(false) always returns true, only databaseManager.setAutoSave(true) may return false if some validation fails.
Isn’t there some code in your solution that explicitely calls saveData()?
Try a very small sample to show this.
Rob
When I start session or execute my form in browser and before any action event takes place a new empty record gets added to the table. In onShow() event I added statement databaseManager.setAutoSave(false) still adds new empty record in table. I don’t know where I am wrong.
What happens first in your code, the newRecord() call or the setAutoSave(false) call?
Rob
On show() event I am loading all records and code is :
function onShow(firstShow, event) {
foundset.loadRecords('SELECT requestid FROM EMPTIMEOFF WHERE EMP_ID=? ',[globals.EMPID]);
databaseManager.setAutoSave(false)
foundset.sort('start_dts desc');
}
When I debug the code foundset.loadRecords throws an error message:
couldn’t load dataset because foundset had editted records but couldn’t save it
Couldn’t do a sort because there where edited records on this foundset
hardina09,
foundset.loadRecords() wants to save the record changes it has before loading a new set, otherwise these changes would be lost.
If it cannot save some of them due to some validation failing (like null values for non-null fields), you will get this error.
Rob
You are Correct Rob. When I changed databaseManager.setAutoSave(false) to true, it worked absolutely fine
Thanks Rob.