Hi all. I suspect this is a bit of a nube question but I really can’t find an answer anywhere.
As users are registering for my site, using the register() method, I am also taking the time to write their email address and a couple of other items to another collection also. Was using the Contacts collection but accessing it is too challenging.
When I have written to the collection, the email field shows what you see in the image below. The two emails with alerts were input through the code I wrote and the other one was entered directly into the collection as an admin.
When I hover over the yellow alert box, it shows this dialog:
I am listing my code below, hopefully someone can tell me what I am doing wrong? The email address turns up fine in the PrivateMembersInfo collection…placed there by register()…but not when I insert().
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
$w.onReady(function () {
/* some other code runs here to build a lit for a pull down...it works fine and I removed it for clarity */
//await submit button click
$w("#registerButton").onClick( (event) => {
var email = $w("#email").value;
var password = $w("#password").value;
var first = $w("#firstName").value;
var last = $w("#lastName").value;
var organisation = $w("#orgDropdown").value;
var role = $w("#role").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName":first,
"lastName":last,
"emails":[email],
"YourRole":role,
"Organisation":organisation,
}
} )
.then( (result) => {
let resultStatus = result.status;
let toInsert = {
"email":email,
"firstName":first,
"lastName":last,
"org":organisation,
};
wixData.insert("IndividualsInfo", toInsert)
.then( (results) => {
let item = results; //see item below
})
.catch( (err) => {
let errorMsg = err;
});
wixWindow.lightbox.close();
wixWindow.openLightbox("Successful Reg");
} );
} );
});