Cancel new record transaction -> deletes existing record

Questions, tips and tricks and techniques for scripting in Servoy

Cancel new record transaction -> deletes existing record

Postby djlapin » Wed Apr 11, 2012 11:38 am

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,

Code: Select all
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,

Code: Select all
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
Attachments
User_tabpanel_list.png
User_tabpanel_list.png (21.24 KiB) Viewed 2751 times
djlapin
 
Posts: 309
Joined: Fri Feb 18, 2011 9:36 am
Location: San Francisco, CA

Re: Cancel new record transaction -> deletes existing record

Postby jcompagner » Tue May 01, 2012 9:43 am

the difference is in:

databaseManager.rollbackTransaction();

that will also by default rollback the edited records, please check the boolean argument
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Cancel new record transaction -> deletes existing record

Postby djlapin » Thu May 03, 2012 5:31 pm

Hi Johan,

Which Boolean argument are you referring to?

But the new record is created in the list, outside of the transaction. The transaction is started in the onShow of the dialog. So the rollbackTransaction should not delete the record itself, right?

Thank you for responding,
Don
djlapin
 
Posts: 309
Joined: Fri Feb 18, 2011 9:36 am
Location: San Francisco, CA

Re: Cancel new record transaction -> deletes existing record

Postby jcompagner » Thu May 03, 2012 10:21 pm

since 6.0:

http://wiki.servoy.com/display/public/D ... ransaction

if you do rollbackTransaction then by default we also rollback all edited records.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 11 guests

cron