Reference is broken

Hello, I’ve searched so much, waited for answers and couldn’t get my head around this issue, and would appreciateyour help.
I have two databases, first database is to collect shops information, second database is to collect every shop’s product they post, therefore every product is referenced to the owner of the product by userId, the code simplified below :-

let toSave = {
“owner”: wixUsers.currentUser.id
}
wixData.insert(“ads”, toSave)

After posting all the information is inserted correctly but the reference field is always broken and when I click the field it fixes it and chooses the id that was inserted, I tried .toString but still didn’t work, so i would be very glad to have an answer for this problem.
Below an image that has the code and information that i am inserting to the ads database (second database)

I have figured out a long and unprofessional way to this problem but might help Others,
I used the Owner _id field from the shops(vendors) dataset in a page as a text and inserted it into the reference field of posts database.

let toSave = {
“Owner” $w(‘#ID’).text
WixData.insert(“posts”, toSave)
}

1 Like