Adding references to new records

So let’s say we ask the user a couple questions and Destination if the user answers Tel Aviv then the record is created and the field Destination (reference) it is referenced to Tel Aviv.
I’m thinking maybe I can make the value be the record ID…

Then we direct the user to a dynamic page that includes their personal info and the information we have for thedestination.

Hi Carlos,

Could you please supply some more infroamtion on what exactly are you trying to achieve?

I’m getting you right, you are trying to build a forum which is connected to a collection of users in which the destination filed is a reference field from a destination collection

https://www.wix.com/code/home/tutorials-custom-form

following the above you’d like to define a dynamic page on top of the users collection

Displaying Database Content on a Dynamic Item Page | Help Center | Wix.com (specifically #4)

And have the user redirected to his personal info page upon save of the form

Hope those links will help you achieve those capabilities

Thanks
Adi

I’m using this code and it is working out, however I am unable to retrive the values from my inputs. I can’t use $w selectors before the page is ready and I can only export an event function at top level. I’m confussed.

I need to trigger this with an OnClick event and the information conencted to the inputs.

import wixData from 'wix-data';

// ...

let countryId = "id-of-usa-item";

let toInsert = {
  "title":        "Mr.",
  "first_name":   "John",
  "last_name":    "Doe",
  "country":      countryId
};

wixData.insert("myCollection", toInsert)
  .then( (results) => {
    let item = results; //see item below
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );

/*  item is:
 *
 *  {
 *    "_id":          "rifk4nrk-dj4o-djhe-oidk-fnoqw4oiglk4i",
 *    "_owner":       "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
 *    "_createdDate": "2017-05-24T12:33:18.938Z",
 *    "_updatedDate": "2017-05-24T12:33:18.938Z",
 *    "title":        "Mr.",
 *    "first_name":   "John",
 *    "last_name":    "Doe",
 *    "country":      "id-of-usa-item"
 *  }
 */

Hi,

Have you tried looking into adding an onChange event on a text input field which will then call your exported function to execute your business logic
http://www.wix.com/code/reference/$w.TextInput.html#onChange

Adi