Hello, i am trying to create a complex Platform with Wix Studio. Currently i am having trouble saving a members contact Info into a Collection, after the member (who is logged in) fills out Input elements, which are saved to a collection.
Example: A User logs in on my Website. He then wants to add a Service to his account. I have made a Form with Input elements, where the user can fill out the necessary Information to add a Service. This Information is then stored in a Collection.
In my backend, inside the collection, i can see the Information that was inputed. What i cant see is from which User the Submission was.
I would like it, when a logged in User fills out the input elements, that it automatically saves the users Account Info (for example Name and Email), so i can identify which input belongs to which member in my collection.
The submissions probably have Owner (_owner), but you have to select it to be shown. This is the _id of the user who submitted the form.
Are you using a dataset to submit the data? If so you should use getMember() to get the info from the member, then you can use setFieldValue() to set the value in the dataset.
Where can i find the ID of the User? I am using the standard Wix Login Form, which then adds any members who login to my Contacts List.
The Form to add a service (created with Input elements) is only accessible for logged in members. This Info is then saved in a Dataset and collected in a collection. Im not sure how to use the getMember() or setFieldValue()… Here are some screenshots:
If you click Manage Forms when viewing the database you’ll see some fields that are unchecked, so they won’t show. One of them is the Owner field, which should contain the _id of the member who added the item to the database.
But, if you want to put the name and email of the person submitting you’ll want some code like this:
If you just open the coding panel for the page where the form is you can copy/paste the code. Just select the dataset and you should be able to see it’s name, make it match with where I wrote datasetName (or do the shortcut and change datasetName to dataset1, and it will probably work if that’s the only dataset there)