Hi,
I’ve been using Corvid to build my website for around 2 months now. Love Corvid by the way.
However there’s one thing bugs me around a lot. It’s in the titles. Especially things that has to do with Data Collections.
Sometimes, when I hit the Submit button, it inserts a new item to the collection, but sometimes, after about 10 successful insert, instead of inserting, it updates an item in the collection.
Oh and then there’s this User Input that just won’t submit its value to a field in my collection.
I’m so frustrated. If it doesn’t work, then I’d rather it stay that way forever, so I can know where the error is.
Oh believe me I’ve searched a lot on the forum for the solution: Permissions settings, Hooks, viewing the Console,… It just doesn’t work.
Is it because Ascend (I’m using Corvid with all the free plans). If it is, can you confirm that the Submission errors I mentioned above has to do with the restricted number of form submissions with the free Ascend Plan?
Your question is quite vague. You’ll have to post your code if you want a real answer.
Here’s the code. Basically it’s a page with User Input elements and a submit button. The problem is #input13.value never gets inserted into the collection’s field.
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
$w.onReady( function () {
// GET CURRENT USER’S EMAIL
var user = wixUsers.currentUser
user.getEmail()
.then((email) => {
var userEmail = email;
// INSERT CURRENT USER’S EMAIL
$w(“#input12”).value = userEmail;
console.log($w(“#input12”).value)
// GET AND INSERT CURRENT USER’S NAME
wixData.query(“PublikMembersDatabase”)
.eq(“loginEmail”, userEmail)
.find()
.then((results) => {
var item = results.items;
$w(“#input13”).value = item[0].name;
console.log($w(“#input13”).value)
// DISPLAY CURRENT USER’S NAME
$w(“#text27”).text = item[0].name;
})
. catch ((error) => {
let errorMsg = error.message;
console.log(errorMsg);
})
})
})
// INSERT GSEmail to OffersFromPH
export function button5_click(event) {
if ($w(“#text29”).isVisible === false ) {
let GSEmailInsert = $w(“#input12”).value
wixData.insert(“OffersFromPH”, GSEmailInsert)
.then((results) => {
let item = results;
})
. catch ((err) => {
let errorMsg = err;
});
}
}
You mention insert and update, what are you trying to do, have a read of the reference for both of them.
https://www.wix.com/corvid/reference/wix-data.html#insert
https://www.wix.com/corvid/reference/wix-data.html#update
https://www.wix.com/corvid/reference/wix-data.html#save
Use the function getEmail():
let user = wixUsers.currentUser;
let userEmail;
user.getEmail()
.then( (email) => {
userEmail = email;
} );
Create the variable “userEmail” at the global scope in order to use it outside the function’s scope.
Now, in order to add the “userEmail” field to the collection, use the function insert().
Have you read the api references for each of them and their functions?
https://www.wix.com/corvid/reference/wix-users.html
https://www.wix.com/corvid/reference/wix-users.User.html#getEmail
https://www.wix.com/corvid/reference/wix-data.html
https://www.wix.com/corvid/reference/wix-data.html#query
Connecting CMS collection content to your site | Help Center | Wix.com
https://www.wix.com/corvid/tutorial/how-to-create-a-custom-form-and-connect-it-to-a-database
Finally, when you are talking about your PublicMembersDataset, you don’t by any chance mean the Wix Members apps own PrivateMembersData collection do you which is read only and can’t be updated?
Also, if you are then to query it, it needs it’s full name in the query itself as Members/PrivateMembersData.
See here for the collection info.
Velo: Wix Members "PrivateMembersData" Collection Fields | Help Center | Wix.com