Page 1 of 1

key from new record

PostPosted: Tue Nov 28, 2017 5:06 pm
by nick1461658753
Why does a foundset not return the key of a new record?

Code: Select all

FS.newRecord( );
FS.value1= "some value";
FS.value2=  "some other value";
FS.value3=  "another value";
databaseManager.saveData( FS );

CFS.FK= FS.id;


So I want to save the key of the new record in FS in a FK column in CFS. But FS.id is empty after the saveData. Why does it lose it's record after saving and why does it not automatically return the primary key after making a new record?
How can I get the id of FS easily and reliably to store in CFS?

Re: key from new record

PostPosted: Thu Dec 07, 2017 2:29 pm
by rafig
Hi
try doing a refresh of records from foundset and then get record one
Code: Select all
databaseManager.refreshRecordFromDatabase(FS, 1);
var rec = FS.getRecord(1) ;
CFS.FK= rec.id;


Rafi

Re: key from new record

PostPosted: Mon Dec 11, 2017 2:51 pm
by juan.cristobo
Or try this:
Code: Select all
var rec = FS.getRecord(FS.newRecord());
rec.value1= "some value";
rec.value2=  "some other value";
rec.value3=  "another value";
databaseManager.saveData(rec);

CFS.FK= rec.id;