Can You Return id of Uploaded Record?

I am uploading information to a record in Database: A, I then want to store the automatically generated id of that record in Database: B with other information. Is there a way I can get the database to return the id of the newly created record in Database: A or will I have to search for it? Given that it is possible for records in Database: A to be identically and almost so, searching for the newly created record may yield multiple results.

Hell Anralore,

Do you use a —> dataset?

I use this method:

let toInsert = {

‘name’ : $w( “#input1” ).value,
‘description’ : $w( “#richTextBox1” ).value,
‘founder’ : Login,

            };  // End of Insert 

            wixData.insert( "DataBaseA" , toInsert) 

            .then( (results) => { 

let item = results;
})
. catch ( (err) => {
let errorMag = err;
} )

Ok Anralore,
i don’t think that i have today enough time to reconstruct your issue,
but what if you would use —> console.log funktion to find your solution?

Are you familiar with → console-logging?

What i mean is —> try to find out what happens in the CODE
For example:
You want to know what is the result after this code-line here…

let item = results

…so just do a —> console-log-querry…

console.log(item)

It will show you what “item” looks like. (PRESS F-12 in google-browser and go to —> CONSOLE)

So what you get if you make a further console-querry like this one…

console.log(item[0])

…or something like that …

console.log(item[0]._id)

…or that…

console.log(item[0]._owner)

…or that…

console.log(item[0].title)
console.log(item[0].name)
console.log(item[0].description)
console.log(item[0].founder)

…and what if you change the number like that…

console.log(item[1]._id)
console.log(item[1].title)
console.log(item[1].name)
console.log(item[1].description)
console.log(item[1].founder)

Perhaps this method will help you to find your solution.

Thank you russian-dima ,
That has solved my problem.

I was familiar with logging. I am dyslexic and to be honest I never noticed that " let item = results; " was there. Thank you for pointing that out.

Sometimes we do not see the tree in the forest (it’s an german saying/adage)
Its a normal phenomenon, it happens also often to me :grin: