Perfect. I’ve got the code almost working, but I’m missing something. Would you mind taking a look? My dataset is called MyChallenges, and the submit button is button_7. It says I haven’t defined userEmail (I tried, but must have missed something), and that I haven’t defined the selector. Should I be using the button instead of the database?
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
let user = wixUsers.currentUser;
let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user.loggedIn; // true
let userRole = user.role; // “Member”
user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com”
} );
$w(“#myChallenges”).onBeforeSave( () => {
$w(“#myChallenges”).setFieldValue(‘email’, userEmail);
});