Consult database data for java functions

Hey, everybody, I need some help integrating this function:

I created a contact form where by entering the data I need and pressing the “send” button the system generates an automatic pdf with the data entered in the form.

So far so good, the model works.

Now I need to go a bit deeper:

I created a database and an internal wix dataset and I would like that every time a user buys a product, in the database is added the customer’s email and a numerical value (to be set according to the product purchased).

Once set up this database I need that every time a user fills in the form and downloads the pdf, the value assigned to that user drops by 1.

Ex. The customer buys a product, in the database will appear the customer’s email and the value 10. The customer fills the form and download the pdf, at this point the value in the database must be 9.

If the value in the database is 0 the customer will not be able to download the pdf.

I hope I have been clear and I hope for your help.
Good day and happy New Year!

1 Like

This has already been done for user submits only the one form as shown here.
https://www.wix.com/corvid/forum/community-discussion/code-to-allow-user-account-to-fill-a-form-just-one-time

For adding one every time the user clicks the button see here.
Increment Button with 1

Maybe you can take it and try to use some of it for your page to count the number of times the user downloads the pdf file and then once it gets to 10 or 0, to have a message pop up saying limit reached.