When the user presses a (+) button next to a table-view list of users (a tab panel list), I add the new record to the table view, and then display the new record in a data entry form,
function onClick_addUser(event) {
forms.user_info_incl.foundset.newRecord(false);
forms.user_info_incl.usr_tenant_id = selpa_select_id;
globals.newRecordFormName = 'user_info_i'
var editUserWin = application.createWindow('editUserWin',JSWindow.MODAL_DIALOG);
editUserWin.title = "Add new program user..."
editUserWin.show(forms.user_info_i);
}
For a new record, the data entry form (user_info_i) acquires a lock and begins a transaction in the onShow.
If the user cancels the new record, I am doing this onAction,
function onClick_bCancel(event) {
var editUserWin = application.getWindow('editUserWin');
if(databaseManager.hasTransaction()) {
databaseManager.rollbackTransaction();
var lockName = 'user_info_' + usr_user_info_id;
databaseManager.releaseAllLocks(lockName);
}
if (globals.newRecordFormName == 'user_info_i') { // it is a newly-created record
forms.user_info_i.controller.deleteRecord();
}
editUserWin.destroy();
}
When the program returns to the form showing the tab panel list, there is one less existing record in the list. As long as I don’t include the controller.deleteRecord() in the cancel, I’m okay.
In other areas of the program, the same code (with the deleteRecord()) works as I would expect it to – the new record (created outside the transaction) is deleted in the table view.
The table view and the data entry form share the foundset.
What is different about this case?
Thank you,
Don