You can use the member Id as form submission id (field key: _id).
The system will not let you submit a new record with the same id and will return an error (error code WDE0074).
Once it returns this error - display an error message “A form with this email has been already submitted”.
If a visitor can submits the form without logging-in, you should use the email address instead.
I don’t know if you have the option to create a data index (I think it got released to user in the UK and maybe Partners but not to all users yet).
So click the collection ‘More Actions’ menu and see if there’s indexes button.
If there is, click it and create a UNIQE index for your email field (the error for duplicates will be WDE0123 );
If you don’t have the indexes option, you should create a hash UUID that represents the email and use it as an _id.
Option2 (if you don’t have the indexes) -
Go to the Code Packages > NPM and install the uuid-by-string package.
Then on backend/data.js file put something like:
const getUuid = require('uuid-by-string');
export function SubmissionsCollection_beforeInsert((item, context) => {
item._id = getUuid(item.email);
return item;
})
//instead of SubmissionsCollection use your own collection name
JD you have been super helpful. The indexes are working in that only the first unique form submission (based on email) is accepted. I had two follow up questions summed up in the below video link.
My follow up questions to you are enumerated in the video but also below:
While the submissions table only accepts the first submission by a unique email, I still get a “thank you for submitting” on the form. Is there a way for the form to have an custom message if it detects that this is the second, third, fourth etc time a user is submitting with the same email?
Is it possible to upload a list of acceptable emails (exclusive) to the content manage and have the form reject any submissions that weren’t on that list of approved emails?
Hi Alison,
Personally, I almost never use these ready-made Wix forms (I create my custom forms instead), so I don’t really know how customizable these form apps are). Maybe you can use the following events to catch the error: https://www.wix.com/velo/reference/wix-crm/$w-wixformsubmittedevent
Try to put a console.log() inside and see what error it logs.
If it catches the error (WDE0074) show an text element with the message inside.
If not - create a custom form and either connect it to a dataset (see events here and here ) or run a direct insert .
As for your second question. Sure it’s possible (at least with custom form. Maybe event with the WixForm ).
Create a database collection (“WhiteListedEmails”) and put the emails there. And do something like this:
P.S. if you don’t want to send the email white list to the front-end due to security consideration, there’s an alternative way to do it in the backend (please let me know).