Get most recent ID entered?

Get most recent ID entered?

Hi Zoho,

I have a script adding records to a form.
in this script, after adding the record to the main form, I need to get its ID in order to insert data to its subforms using bidirectional lookup.

Since the records are inserted automatically, it happens very quickly, so a fetch that is sorted by Added_Time does not work. I don't want to use fields entered by the user since they can be identical. 

Any idea how can I get the last added ID?


the script look like this:

for each EachIDforImport in Vals_for_Import_ID_List
{
insert into Mainform
[ -- data inserted---]
                        -- get the ID of the entry just inserted --
                        insert into Subform
[ -- data inserted---]
                  }



thanks!

Ravid