Hi @cwvega76 , I was sure that by this time you might have found the solution, but as stated in the solution above, if you follow that technique, you can automatically set the right value based on Id received from primary dataset, by using just codes.
Else, the other way around is to add a dropdown element and set it to the reference field, select the option manually before you upload the data ,as understood by you.
Thanks. No data to upload, both the primary dataset and the secondary already contain all the data. I still have not implemented this. Perhaps you could tell me in terms of MY datasets and fields exactly what I need to do?
Primary dataset “CARS” has an email address that I use in wix code to look in the secondary dataset “PEOPLE” to retrieve the name, city, state, zip and phone number of the “owner” of the car when listing the cars or a specific car by dash#ID. The car database as currently exists does NOT have that email defined as a reference field. Therefore I cannot query the CARS dataset for those that exist in a given state, which was my original intent as posted in August 2019. I simply gave up.
the data type of a reference link in wix is just text, and it should be the _id of the referenced object. if your users submit forms, then the ‘_owner’ field in the object you are inserting into the table is the same as the logged in member’s id ( ‘_id’).
here’s an example of adding a reference field into wix table through a data hook:
export function Students_beforeInsert ( item , context ) {
console . log ( “INSIDE STUDENTS INSERT HOOK” )
console . log ( item )
// formatting the student’s name
item.title = toCamelCase ( item.title );
// adding the reference link of the parent (member who is submitting form data) to the ‘Students’ table
item.linkedParent = item._owner
**return** item
}