Crumpled Fabric

0

Save Calculated Field Using WIX Data Hooks

Click URL to copy

Sep 21, 2021

1 min read

WIX Ideas Team

Tags: WIX Data Velo by WIX


Have you wanted to save data from a calculated field? Then you are in the right place.


Saving a solution or answer to WIX database collection is easier than expected. Using WIX Data Hooks, it is absolutely achievable to save a calculated field before it is inserted into the database.


WHAT I DID


The steps to achieving this procedure is quite basic. Assuming you already know the formula to use then the rest is merely assigning your answer to the answer field in your database. Before adding the code, I connected my form element(Date Picker) to data. WHY? The date picker value (Year selected) is what I used for the calculation. So it was important I took the value from there and substracted from the current year using new Date() object. I then added my data hook from by clicking on the three dot icon option for my database and clicked on Add/Remove Hooks.






Next I added the beforeInsert function and started modifying my code. My edited code looked something like that.




In order to calculate the date picker field, I decided to intercept the values before it was inserted and used it to calculate for the age. This date was then saved in a field in my database. Eventually, I will use this field in my website displaying it or using it for another operation it comes to that.


FINAL DISCUSSION


Well, that rounds up technically every step. My final code is below and you can copy and paste for personal use. I hope you enjoyed this tutorial, don't forget to LIKE/SUBSCRIBE






Code



LEAVE A COMMENT

WRITE A COMMENT

Thanks for leaving a comment🎉

Walter

Walter

8/8/22

More Details? Watch video

Hi, you can click here to watch the video https://www.youtube.com/watch?v=9bx7-nBeZ5c

Walter

Walter

7/11/22

For you

Walter Odibi

Walter Odibi

4/18/22

Awesome Feature

This tutorial shows you how to display views on your Wix repeater.

📺WATCH VIDEO HERE https://www.youtube.com/watch?v=Iz7SdaCSdXg

Walter Odibi

Walter Odibi

4/18/22

Amazing tutorial

This amazing tutorial will show you how to a comment section to your WIX dynamic page.

📺WATCH VIDEO HERE https://www.youtube.com/watch?v=f8-vJQFNZ_c

Walter Odibi

Walter Odibi

4/10/22

Great Feature🎉

This amazing tutorial will show you how to add a visitor view counter to your WIX dynamic page.

🚩MORE TUTORIALS https://www.wixgenius.com/wix-tutorials

LOAD MORE 🎉

RELATED TUTORIALS 🚀

Quote Calculator

Quote Calculator

Set up a quote calculator to enable your site visitors to easily manually build a quote for a service you offer.