Getting the user name and insert to collection

Hey guys,

I’m trying to get the name of a user from Members/PrivateDat and write it in another collection when the user clicks on a submit event. So far I’m able to send the url and the id but I don’t know why it keeps telling me that my name variable is not defined. I checked the field in the collection and everything seems to be in order.

Help!

Hi,
In your case, userName variable is not reachable out of wixData.query.

Hi Alexander, where exactly should I declare it? I tired within the other function but still doesn’t work. Could you write here how you would do it?

When I try declaring it inside of the other function i get an unexpected


token

https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

Tried this but still nothing happens