Help putting code into async and wait...

Hi guys,

Ive recently had an issue with my site where by my submit button to submit data to a dataset was also linked via code and since an update to wix rendering the two things are now causing a conflict. Alek at wix help has told me what i need to do but im stuck on how to do it.

Below is the snippet of code that i need to wrap in a async function and await before the page relocates aparrently. heres what alex wrote to me.

Hi Dan,
Thank you for getting back to us and providing the screencasts with comments.

I’m sorry for all the confusion and any caused inconvenience, I will clarify everything to you step by step:

  • Currently, when you click the submit button, you populate the values of the fields into the dataset using code. However, submit action and redirection is done through the button data connection settings (both on diet creator v2 and diets (full name, id) pages).

  • Such implementation causes conflict (the submit and redirection happens before the data actually populates into the dataset inside the click function), and the data you are trying to set using code doesn’t populate into the diets collection (for example meal 1, meal 2 fields, etc.).

  • On the diets (full name, id) page where you edit the diets, the data for the check list is taken from the collection. As there’s no data in it, it displays nothing, blank (as I’ve added Almonds to the collection, if you open my test account on the edit diets page, you will see these two meals).

  • This implementation working previously was a bug and could lead to unexpected issues because of unpredictability of how the browser might render it. This bug was fixed as a part of the general improvement of our site’s renderer.

  • It still works in preview, because the preview still uses and older version of the renderer and should be fixed with one of the future updates.
    We suggest to do the following to avoid conflicts in future:

  • Create a separate function where you will use the .setFieldValue function to populate all the relevant fields of the dataset.

  • Make the submit button click event async.

  • Inside the submit click, call the function where you set the field values (with the await condition, to make sure all other actions happen only after the fields are set to the relevant values).

  • Once it executes, perform the save operation for the relevant dataset (the dataset the submit button is currently connected to, using data binding), also with the await parameter, to make sure the redirection doesn’t happen before the save operation is complete.

  • As the last part of the click event, use the wixLocation.to() function to redirect to the relevant page once the data is saved.
    I hope this clarifies the current behavior and the suggestion for resolving it was helpful.
    Please let us know if you have further question or need further assistance.
    Have a great day!

Alex, Velo by Wix Expert

Can one of you wonderful people please adjust this code to what it should be ? and add the relocation after the data submits? what does he mean by data binding using the button as a button and linking it to a data set again??? really confused sorry guys for the long mail.

//Submitions
export function submitButton_click(event) {
//Main page submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘fullName’ , $w( ‘#longNametext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘mealType’ , $w( ‘#mealTypetext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘date’ , $w( ‘#dateText’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘email’ , $w( ‘#emailAddresstext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘firstName’ , $w( ‘#firstNametext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘clientsWeightAtTimeOfCreatingDiet’ , $w( ‘#weightText’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘comment’ , $w( ‘#commentsText’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘proteinTotal’ , $w( ‘#proteinSumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘carbohydrateTotal’ , $w( ‘#carbohydrateSumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘calorieTotal’ , $w( ‘#caloriesSumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘fatTotal’ , $w( ‘#fatSumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘bmrTotaltolose1kg’ , $w( ‘#lose1Kgweeksumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘bmrTotaltolose05Kg’ , $w( ‘#loseHalfkgweeksumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘bmrTotaltomaintainweight’ , $w( ‘#maintainWeightweeksumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘bmrTotaltogain05kg’ , $w( ‘#gainHalfkgweeksumtext’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘bmrTotaltogain1kg’ , $w( ‘#gain1Kgweeksumtext’ ).text);
//Meal 1 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time1’ , $w( ‘#time1Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food1’ , $w( ‘#food1Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity1’ , $w( ‘#qty1Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement1’ , $w( ‘#measurement1Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food2’ , $w( ‘#food2Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity2’ , $w( ‘#qty2Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement2’ , $w( ‘#measurement2Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food3’ , $w( ‘#food3Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity3’ , $w( ‘#qty3Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement3’ , $w( ‘#measurement3Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food4’ , $w( ‘#food4Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity4’ , $w( ‘#qty4Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement4’ , $w( ‘#measurement4Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food5’ , $w( ‘#food5Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity5’ , $w( ‘#qty5Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement5’ , $w( ‘#measurement5Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food6’ , $w( ‘#food6Meal1text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity6’ , $w( ‘#qty6Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement6’ , $w( ‘#measurement6Text’ ).value);
//Meal 2 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time2’ , $w( ‘#time2Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food7’ , $w( ‘#food7Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity7’ , $w( ‘#qty7Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement7’ , $w( ‘#measurement7Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food8’ , $w( ‘#food8Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity8’ , $w( ‘#qty8Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement8’ , $w( ‘#measurement8Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food9’ , $w( ‘#food9Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity9’ , $w( ‘#qty9Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement9’ , $w( ‘#measurement9Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food10’ , $w( ‘#food10Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity10’ , $w( ‘#qty10Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement10’ , $w( ‘#measurement10Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food11’ , $w( ‘#food11Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity11’ , $w( ‘#qty11Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement11’ , $w( ‘#measurement11Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food12’ , $w( ‘#food12Meal2text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity12’ , $w( ‘#qty12Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement12’ , $w( ‘#measurement12Text’ ).value);
//Meal 3 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time3’ , $w( ‘#time3Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food13’ , $w( ‘#food13Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity13’ , $w( ‘#qty13Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement13’ , $w( ‘#measurement13Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food14’ , $w( ‘#food14Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity14’ , $w( ‘#qty14Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement14’ , $w( ‘#measurement14Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food15’ , $w( ‘#food15Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity15’ , $w( ‘#qty15Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement15’ , $w( ‘#measurement15Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food16’ , $w( ‘#food16Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity16’ , $w( ‘#qty16Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement16’ , $w( ‘#measurement16Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food17’ , $w( ‘#food17Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity17’ , $w( ‘#qty17Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement17’ , $w( ‘#measurement17Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food18’ , $w( ‘#food18Meal3text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity18’ , $w( ‘#qty18Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement18’ , $w( ‘#measurement18Text’ ).value);
//Meal 4 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time4’ , $w( ‘#time4Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food19’ , $w( ‘#food19Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity19’ , $w( ‘#qty19Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement19’ , $w( ‘#measurement19Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food20’ , $w( ‘#food20Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity20’ , $w( ‘#qty20Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement20’ , $w( ‘#measurement20Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food21’ , $w( ‘#food21Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity21’ , $w( ‘#qty21Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement21’ , $w( ‘#measurement21Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food22’ , $w( ‘#food22Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity22’ , $w( ‘#qty22Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement22’ , $w( ‘#measurement21Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food23’ , $w( ‘#food23Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity23’ , $w( ‘#qty23Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement23’ , $w( ‘#measurement23Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food24’ , $w( ‘#food24Meal4text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity24’ , $w( ‘#qty24Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement24’ , $w( ‘#measurement24Text’ ).value);
//Meal 5 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time5’ , $w( ‘#time5Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food25’ , $w( ‘#food25Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity25’ , $w( ‘#qty25Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement25’ , $w( ‘#measurement25Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food26’ , $w( ‘#food26Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity26’ , $w( ‘#qty26Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement26’ , $w( ‘#measurement26Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food27’ , $w( ‘#food27Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity27’ , $w( ‘#qty27Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement27’ , $w( ‘#measurement27Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food28’ , $w( ‘#food28Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity28’ , $w( ‘#qty28Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement28’ , $w( ‘#measurement28Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food29’ , $w( ‘#food29Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity29’ , $w( ‘#qty29Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement29’ , $w( ‘#measurement29Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food30’ , $w( ‘#food30Meal5text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity30’ , $w( ‘#qty30Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement30’ , $w( ‘#measurement30Text’ ).value);
//Meal 6 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time6’ , $w( ‘#time6Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food31’ , $w( ‘#food31Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity31’ , $w( ‘#qty31Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement31’ , $w( ‘#measurement31Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food32’ , $w( ‘#food32Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity32’ , $w( ‘#qty32Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement32’ , $w( ‘#measurement32Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food33’ , $w( ‘#food33Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity33’ , $w( ‘#qty33Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement33’ , $w( ‘#measurement33Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food34’ , $w( ‘#food34Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity34’ , $w( ‘#qty34Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement34’ , $w( ‘#measurement34Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food35’ , $w( ‘#food35Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity35’ , $w( ‘#qty35Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement35’ , $w( ‘#measurement35Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food36’ , $w( ‘#food36Meal6text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity36’ , $w( ‘#qty36Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement36’ , $w( ‘#measurement36Text’ ).value);
//Meal 7 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time7’ , $w( ‘#time7Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food37’ , $w( ‘#food37Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity37’ , $w( ‘#qty37Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement37’ , $w( ‘#measurement37Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food38’ , $w( ‘#food38Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity38’ , $w( ‘#qty38Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement38’ , $w( ‘#measurement38Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food39’ , $w( ‘#food39Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity39’ , $w( ‘#qty39Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement39’ , $w( ‘#measurement39Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food40’ , $w( ‘#food40Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity40’ , $w( ‘#qty40Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement40’ , $w( ‘#measurement40Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food41’ , $w( ‘#food41Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity41’ , $w( ‘#qty41Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement41’ , $w( ‘#measurement41Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food42’ , $w( ‘#food42Meal7text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity42’ , $w( ‘#qty42Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement42’ , $w( ‘#measurement42Text’ ).value);
//Meal 8 submitions
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘time8’ , $w( ‘#time8Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food43’ , $w( ‘#food43Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity43’ , $w( ‘#qty43Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement43’ , $w( ‘#measurement43Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food44’ , $w( ‘#food44Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity44’ , $w( ‘#qty44Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement44’ , $w( ‘#measurement44Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food45’ , $w( ‘#food45Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity45’ , $w( ‘#qty45Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement45’ , $w( ‘#measurement45Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food46’ , $w( ‘#food46Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity46’ , $w( ‘#qty46Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement46’ , $w( ‘#measurement46Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food47’ , $w( ‘#food47Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity47’ , $w( ‘#qty47Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement47’ , $w( ‘#measurement47Text’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘food48’ , $w( ‘#food48Meal8text’ ).text);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘quantity48’ , $w( ‘#qty48Dropdown’ ).value);
$w( ‘#dietsWritedataset’ ).setFieldValue( ‘measurement48’ , $w( ‘#measurement48Text’ ).value);
}

From what I understand, you have the Submit button connected to a dataset submit action. And, you also have an onClick() event handler connected to that same Submit button.

So, what happens is that the onClick() function “overrides” the dataset submit action. So, what happens is is that the onClick() function executes, but the dataset submit action does not get executed.

What I don’t understand is how this is related to async and await .

Please explain what it is you’re trying to accomplish. What works, what doesn’t, and show the relevant code in a code block.

Yes that’s what wix are telling me yes the submit button is working before the code apparently so they recommend i switch to code i just dont know how to do it.

I have a diet creator which when i create a diet all data should go into the data base. this has been fine for 3 years now but apparently wix have update the rendering their end which has now stopped my site working and left me to fix it which is very good!!! expect i don’t know how to fix it hence Im here.

My site has been down 3 weeks now and I’ve lost a lot of business because of this,

Any way the code Im using to set field values. is as above i just need to know how to set this up with the A sync included in the code and the page redirecting after its submitted.

Id even be willing to pay someone to help me fix this im in need so badly.

Here is the full code for the page however the issue is around the Submit_OnClick function only and setting the fields. as i said before it was working fine until wix changed the rendering their end.

I cannot publish the full code here as its too big

Please post the URL and explain how to see the problem.

BTW - It might have worked before, but connecting a Submit button to an onClick() function is incorrect and results in unexpected results.

HI i cant give you access to site as its Admin only

below is the video that i sent to Alek at Wix.

https://drive.google.com/file/d/1nAcgYaHm67uFJ7kUI52zAg_XDWZdDUqK/view?usp=sharing

HI Does anyone know how i can make this work as per wix instructions? im really struggling ?

Need a URL to be able to inspect.

1 Like

https://www.fmphysiques.com/Diets/Albert-Benecke/7a9d4862-7bd1-460e-bca4-e482097102f0

Thanks Yisreal

Hey Dan,

Understand that we are unable to debug or rewrite complex code and page configurations. You have over 4200 lines of code - that’s a lot to figure out.

You should move the import statements to the top of the code file. Also, move the onReady() function to the top of the code as a best practice.

You have a number of lines of code that are flagged as errors. The error message indicates that you need to convert those values to Numbers in order to perform a calculation.

You received a fairly comprehensive and complete answer from Alex. The main issue that you have is that you are performing I don’t know how many queries one after the next without properly handling the Promises returned by the queries.

You will need to redesign and reorganize your site’s code. You might want to consider hiring a Velo expert to help you with your site development.