Withe amazing help of the Wix Code team, I was able to prevent duplicated submissions into my database.
Now i need some help displaying an error message when an error occurs
Withe amazing help of the Wix Code team, I was able to prevent duplicated submissions into my database.
Now i need some help displaying an error message when an error occurs
Hi,
A simple solution might be to add a text component to your page, set it to hidden by default and change it to visible on dataset error so the user sees the message only when an error occur.
Does this require any coding in the image I referenced above?
Can you guide me with the specific steps on this?
Assuming you added a text component for the error message called errorText
, you can:
dataset1_onError
you can add the line $w('#errorText').show()
How exactly do I add the âerrorTextâ
I have a few questions:
Assuming I start from step 1:
1.) Iâm adding a text element to be displayed on dataset error.
2.) How do I correct add a text component for the error message called errorText
, you can2.) How do I program this to display only on error?
in this code: dataset1_onError
you can add the line $w('#errorText').show()
What do I insert where it says: you can add the line
Detailed steps:
dataset1_onError
(line 8 in the code you took a screenshot of) add the following:Thatâs it. You should be good to go
Thanks
One last question Whatâs the reason for this error
Also - This text should only pop up when the database finds duplicate entries. Look:
Any parameters that are declared and not used later prompt this warning. In your case, the âeventâ parameter is declared automatically as it includes some info about the specific message that occurred (see wix-dataset - Velo API Reference - Wix.com for details). If you have no use for it, you can simply omit it, if youâd like.
The prompt only needs to show when dups are found. Error message is not needed since the fields all become red when validation errors are found.
In this case, you need the event
param.
Check whether the error.message
equals the error message you generate in case of duplication (in your example: âcount is more than 0, dups found!â) and only in this case, display the error text.
So your text might look something like that:
if(error.message === 'count is more than 0, dups found!') {
$w('#errorText').show();
}
So, if(error.message === âcount is more than 0, dups found!â) { $w(â#errorTextâ).show(); } needs to be inserted on line 8 of my code for my hidden property?
I know I have a unique request. This request amends some of the steps you mentioned above. Perhaps, we can schedule a call, just so I can learn how to amend the code properly on my own.
I think I need a few changes done.
on line 9.
Iâll see what can be arranged regarding the call you requested. Will be in touch with you in the beginning of the week.
Thanks so Much!
I appreciate this so much
I need help on the same issue. Can someone please help me too? Thanks