I have 2 tables:
- Movim (PK: id_movim)
- Movim_detail (PK: id_movim_detail, FK: id_movim)
From Movim_detail I’m traying to create a new record in table Movim AND a new related record in Movim_detail, but it doesn’t work:
//creating a new record in table Movim
forms.Movim.controller.newRecord();
forms.Movim.creationDate = new Date();
forms.Movim.note = 'new record';
forms.Movim.controller.saveData();
//I need the ID later
var id_m = forms.Movim.id_movim;
//I'm in table Movim_detail, and I want to duplicate de current Record
controller.duplicateRecord();
creationDate = new Date();
//this duplicated record is related to the new record in Movim
id_movim = id_m;
controller.saveData();
In the variable id_m I don’t have the ID of the new record, but the ID of the current record in that table.
If I add forms.Movim.controller.show(); at the beginning of the code, it woks, but I don’t want it ![Sad :(]()
Any ideas?
Hi Log-out,
You could try to change your new record function to include the ‘true’ option which will create the new record on top of the foundset which should then pick up the correct id as in :
//creating a new record in table Movim
forms.Movim.controller.newRecord(true);
forms.Movim.creationDate = new Date();
forms.Movim.note = 'new record';
forms.Movim.controller.saveData();
//I need the ID later
var id_m = forms.Movim.id_movim;
Or try to act on the foundset object itself which allows you the option to select the new record as in :
//creating a new record in table Movim
forms.Movim.foundset.newRecord(true,true);
forms.Movim.creationDate = new Date();
forms.Movim.note = 'new record';
forms.Movim.controller.saveData();
//I need the ID later
var id_m = forms.Movim.id_movim;
One of these may work but its just off the top of my head
Cheers
Harry
Thanks, Harry, but it doesn’t work.
The solution I found is, as I said, adding a controller.show() at the beginning, but this is a “bad” solution… ![Confused :?]()