Hi everyone!
Say you have a form with some elements connected to database and the Save button saves it. On that you are setting some data using setFieldValues. Earlier this used to work. But recently, the data filled using code no longer submits.
When I changed all the form to submit using code only, all the data are submitted.
Did Velo changed stuff?
2 Likes
Can you share the code where you do this?
Hi Kristof,
button10 is the button for saving the form. The form fields are connected to a dataset $w(“#dynamicDataset”). On saving the form, all the fields (connected via editor) gets saved, except the coded one.
export function button10_click(event) {
$w(“#dynamicDataset”).setFieldValue(“amount”, $w(“#amountToCharge”).value);
}
Oke so you linked the button with the dataset to save it to the collection?
Ifso,
Connect the field “amount” with $w(“amountToCharge”) element.
Thisway you don’t need any code and it saves.
Otherwhise unlink the button and add after the setFieldValue()
$w(“#dynamicDataset”).save()
The “amount” field is a calculated one (1 + 1 = “amount”) and is not input by the user. Hence, setFIeldValue.
If i save the dataset in code, it gives an error, as the dataset is already being saved by the button (connected via editor).
So amountToCharge is a calculated value then?
None the less its an element, an element can be connected to the dataset otherwhise if you should have a variable with the calculated value.
A var or let.
Hello everyone, I am coming to this topic to avoid creating a duplicate. I am having the exact same problem! My code worked the same with a save button and a “setFieldValues”. Everything has been working fine for 7 months already, but it looks like wix made a change recently, and it doesn’t work anymore! (if there is any information on this subject I am a taker because I cannot find anything about it, which is unacceptable!)
In my case, it is a lightbox that opens to register for different trainings that I sell on my wix site.
I have on this lightbox only two elements connected to the database: an input field for the email and a button to save the email in the database.
My database has 6 columns for recording customer emails, and its 6 columns correspond to specific automation. The setfieldvalue allowed to save the email in the column in question.
I don’t see how to make my system work any other way … Whereas it used to work great before ! No changes have been made and I am reassured to see that other wix velo users are in the same problem!
Please help me!
Here is my script:
On the training page in question, I add a variable to indicate to the script of the lightbox which training it is. Then I return the variable to the lightbox:
var getformation = "formation1";
export function subscribe_click(event) {
wixWindow.openLightbox("subscribe-formation", getformation);
}
Once the customer opens the lightbox, I get the variable that was on the sales page. It is this variable which will designate where the customer’s email must be stored on the database when he clicks on the button :
var formationemail;
$w.onReady (function() {
let getformation = wixWindow.lightbox.getContext(); // get the formation value
if (getformation === "formation1") {
formationemail = "emailformation1"; // name of database column
}
else if (getformation === "formation2") {
formationemail = "emailformation2"; // name of database column
}
// same, formation3 / formation4 ...
})
export function save_click(event) {
$w('#dataset1').setFieldValue(formationemail, $w('#emailinput').value); // send information in database
}
This script used to work fine before, I didn’t touch anything! Now, when the customer clicks on the save button, an empty box appears in the column in question of the database. What to do wix? Found me a solution! How can we create a business on wix if in the end you change elements without warning after a few months … In the end I find myself with customers who complain because they have not received anything since my automations no longer work because of this bug. So please reply to my message and fix this problem wix! My business depends on it !
It’s best to open a new issue as you will have a better chance of someone answering you…
Please post the URL and explain how to see the issue.
Hello @yisrael-wix this is urgent as you can understand.
The error concerns your service. The Wix community is not responsible and it is indeed an error on your part so it is up to you to take care of this bug as quickly as possible which prevents us from being effective for our customers. so please follow up.
It is not a question of having “better chance of someone answering”, but of course to obtain THE solution of the problem which you created and to take charge from now by your follow-up, rather than d 'an answer that will, again, take my time. It is not for me to take charge of a problem which belongs to you. I pay for it.
My answer which follows the problem of another person already mentioned and future ( because you are going to have still other people impacted ) is precise enough to forward and find a solution to your problem. THANK YOU FOR GIVING US THE SOLUTION QUICKLY .
Forward this topic to your wix team ,
thank you.
@lukasjacqueline I have no idea what the problem is without the URL.
@lukasjacqueline Also, please realize that the Velo Community Forum is not a support forum.
@yisrael-wix thanks for you reply.
Here is the link of the site : https://www.karinelosurdo.com/formation-systeme-sensoriel and thank you in this case for transmitting my message to the support of team wix velo
Lukas
@lukasjacqueline I need more information. Please understand that your site has a good number of pages, and I can’t find the page from the page list in the Editor. Where do I find the page, and what Lightbox is being opened?
I found the Lightbox. Unfortunately it took me some time.
I found the problem. You have the submit button (#button53) connected to the dataset submit action . and you have a sendmail_click() event handler connected to the same (#button53) button. Since you have the button connected to the submit action, when the button is clicked, the submit action is executed - the sendmail_click() function never runs.
You will need to disconnect the sendmail_click() function from the submit button, and do the setFieldValue() in an onBeforeSave() dataset hook.
Thank you very much @yisrael-wix for taking the time to look at my wix site to determine the exact cause of this problem.
Thank you for your professionalism and courtesy
So the problem came from wix since the event handlers worked fine before. How to know that it was about this problem… impossible to know. The lack of communication from wix about this change is very bad taste.
Thanks to @yisrael-wix it’s working again. So I deleted the “onclick” event handler that I had put on my send button. Then I placed this code:
$w.onReady(function(event) {
// SEND INPUT EMAIL TO DATABASE
$w("#dataset1").onBeforeSave( () => {
console.log("email send to database");
$w('#dataset1').setFieldValue(formationemail, $w('#emailinput').value); // add email to database and send a email with automation
});
});
You were quick to solve our problem, you just made people happy @Yisrael (Wix) !
I think the subject of @Wolf Tech can be put in resolved.
Good day to all
Glad I could help.
I understand that “the problem came from wix since the event handlers worked fine before” - however, setting both and event handler and a dataset action on a submit button was wrong, and would often result in unpredictable behavior.
It is true that initially, to achieve what I wanted, it seemed logical to me to use the onclick event handler with, in addition, a data set action on my send button. I would have liked to use the “wixData.query” request to avoid going through the wix GUI options but unfortunately my automations did not work with the wixData.query request. Which is a pity. But who knows, maybe a future feature on wix velo
Now I understand better how all this behaves. I’m sure this topic will help a lot of people.
Hello…
I have the same problem.
My code has been working for months but since February the SetFieldValue doesn’t work like Lukas.
I am currently spending hours trying to resolve this big issue for my business.
@yisrael-wix could you check my code, because I am desperate right now !!
Thank you very much for your quick answer.
Hi @edouardcaumont Did you try the solutions suggested above? Can you show us your code on this topic of conversation please, it will be easier to help you