gte451f:
Guys I have been pulling my hair out with a seemingly simple task.
I have a form based on a parent table and want to create a related child record. Specifically, family->person->parent
So I start a method that does…
family_to_person.newRecord(true);
I can create the new related record but the DB generated ID doesn’t get created right away. Next I try to get the DB generated ID via…
var personid = family_to_person.personid;
I need the value from inside the method to add other related records. This can’t be hard, yet somehow I have managed to make it so.
I have tried saving the data after creating the new record by way of…
controller.saveData();
…with no luck.
I can’t seem to get the DB generatied ID field unless I go to another record them come back.
What in the world am I doing wrong?
Is the pk managed by the database, instead of Servoy, by any chance?
Another little annotation: maybe it won’t give you troubles, but I wouldn’t use the same name for a column and for a variable (I mean “personid”)
Is the pk managed by the database, instead of Servoy, by any chance?
Yes, and I checked that they are actually auto incrementing.
maybe it won’t give you troubles, but I wouldn’t use the same name for a column and for a variable (I mean “personid”)
I noticed that as well and tried renaming the variable to “foo” or “temp” but still no luck.
I guess it boils down to this:
How can I create a new related record via a method then get the database auto incrementing field from that related record later in that method?
Thanks! For similar issue I too did the following:
//Create a new record
var row = religion_ref_2.newRecord(false,false);
var record = religion_ref_2.foundset.getRecord(row) ;
var woman_lawyer_id = record.woman_lawyer_id;
var religion_name = forms.vls_religion.controller.saveData()
The fourth line helps me to avoid an error message since the table’s constraints (where I wanted to create the record) demand for an immediate value on a third table before committing the record.