Hey thank you @mvveiga !!
I followed your explanation and was able to make it work.
Below was I did so it work for me. Thank you.
let theguest = wixData . insert ( “EventsGuest” , toInsert )
. then ( results => { // <= Here you are consuming the promise.
let item = results ; // NEEDED To add this so I could use the promise return values.
$w ( “#txtmessage” ). text = “Guest Added!” ;
$w ( “#txtmessage” ). show ();
$w ( ‘#dataset2’ ). refresh ();
return item ;
})
theguest . then ( ( result ) => {
let myitem = result ;
myId = myitem . _id