Text input filled out from wix-members function to Dataset record

Hi there, I’m stuck at the end of this problem:

I have a custom form that contains several Input fields.
I created a Collection dataset for this Form.
Then, I mapped the Elements and the dataset.
Everything is running as I expected. Easy.

Upgrade
I am interested in enriching this dataset with “CurrentMember” data (member._id) from wix-members source.
So I modified the publicly available script as follows:

import { currentMember } from ‘wix-members’ ;

$w . onReady ( function () {

currentMember . getMember () 
    . then (( member ) => { 

        $w ( '#MemberName' ). value  =  ` ${ member.contactDetails.lastName }  ${ member.contactDetails.firstName } ` ; 

        $w ( '#MemberEmail' ). value  =  member.loginEmail ; 

        **return**  member ; 
    }) 
    . **catch** (( error ) => { 
        console . error ( error ); 
    }); 

});

The result:
The data appears in the corresponding Element IDs.
Great.

The Problem:
The data is transferred to the corresponding Elements. As expected.
I can see it visually (preview) and subsequently in Logs (I log the content of Elements).
However, after submitting the Form, the data from these Elements are not transferred to the Collection dataset even if they are mapped to the corresponding dataset.
After checking in Collection, these records are empty.

Can you advise me on what I am doing wrong?

PS: The Elements will be hidden; the user does not need to see them. However, I need them in datasets.

Thx

The most usual failure everybody do is → mixing ordinary custom code-parts with datasets+options made inside of the PROPERTY-PANEL.

However, after submitting the Form, the data from these Elements are not transferred to the Collection dataset even if they are mapped to the corresponding dataset.

After checking in Collection, these records are empty.

Why this happens?

Well, maybe because you have two different cycles running synchrounous in parralel-mode and the one overrides data of the other.

  1. Where is the CODE for your SUBMISSION? (Oh, you connected your submit-button directly with the dataset, i undertand ) :grin:
    What? You don’t have a code for submission?
    Wait, you setted it up inside of the PROPERTY-PANEL of your connected DATASET ?
    Am i right?

This is all the code (provided by you), which i can find…

import {currentMember} from 'wix-members';

$w.onReady(function() {
    currentMember.getMember()
    .then((member) => {
        let firstName = member.contactDetails.firstName;
        let lastName = member.contactDetails.lastName
        console.log("First-Name: ", firstName);
        console.log("Last-Name: ", lastName);
        $w('#MemberName').value = `${lastName} ${firstName}`;
        $w('#MemberEmail').value = member.loginEmail;
        return member;
    })
    .catch((err)=> {console.error(err);});
});

…so i asume you did all the rest of your setup, with the help of dataset-connections and the ussage of setting-options inside the dataset’s PROPERTY-PANEL.

And now you are expecting that this MIXED-VERSION will work without any problems???

WRONG !!! ----> it won’t !!!

But how to solve it now? → Do we need something like → onBeforeSubmit <— do something???

But when we check the Wix-API → we won’t find such a possibility!

So what now?

But wait, i have something in my nose…, i can smell it already, wait wait…

-----> YES, that must be the right path ----->