Forms, Data Forms ownership

I am trying to add a form to a private member page so that the member can input information into that form and it will be saved as content in their account and then viewable on a table. I then want to be able to create an automation to bring that form data to a google sheet. I can do all of that except I can’t get the owner of the form to the google sheet. When I go to Forms & Submissions, and then choose visible fields in the drop down, it shows owner but it won’t let me select it.

Any ideas on how to achieve this?
Thanks.
Drew

Hi Drew,

You can create your own " owner " field! Set it as a reference to the " PrivateMembersData " collection, and assign it the member’s ID prior to the form submission.

I suppose you know how.

I do not know how to do that.

@drew_kosel no problem, try this:

import members from 'wix-members';
const member = await members.currentMember.getMember();

A) If you’re using a dataset to submit the form, use the onBeforeSave() event handler and the setFieldValue() function to set the value of the reference field.

const dataset = $w('#dataset');

dataset.onReady(() => {
    datasaet.onBeforeSave(() => {
        dataset.setFieldValue('owner', member ? member?._id : undefined);
    })
})

B) If you’re using Wix Data.

import { insert } from 'wix-data';
const obj = {
    name: 'John Doe',
    age: 35,
    owner: member ? member?._id : undefined
}

insert('collection', obj);

Hope this helps~!

Note: The code is not in the correct order, the please follow the JavaScript’s basic tips to organize it.