The best way to use forms...

Hi. I’d like a steer on how to approach a challenge I seem to be facing. For context, it would be generous to class me as a novice with WIX and coding, but I’m working my way through…

I have created a calculator that takes inputs and produces a series of outputs based on math formula. E.g. tell me your consumption variables and I will tell you how much our service will cost, along with usage caps.

I want the data to be output into an email (and possibly later into a payments process, with STRIPE) for internal use. My issue is that I can use a form and get the user input data to be sent as standard, but I haven’t worked out how I can get additional calculated ‘output’ items into the form email. I can’t seem to add fields to the form that code can be used to write to those field. I either need to solve that problem (which is my preferred path), or not to use a form and use text boxes instead and link these to a database…and I don’t know how to export the data from a database in the form of an email.

If anyone can help, particularly with some example code, that would be fantastic. Thank you

First i would suggest to show us a little screenshot of your form or what ever you have in front of your eyes. And you also should tell us which form you use.
Is it perhaps a form from “Wix-Apps” —> “Wix-Forms” ?

Or is it a normal basic-form-element? Something else?

If you are describing a problem, you should always be very precise.

more-INPUT ----> = ----> more-OUTPUT !

I have chosen not to use the Wix forms and have created my own which has a series of input boxes and a series of text boxes. I populate the text boxes based on the entries in the input boxes and this is all working well.

I have a submit button and the database is now populating. Unfortunately it is populating twice - once with values and once without. I only want the row in the database that has the values. If I remove the wixData.insert code I only get the line without data but if I remove the first block of code then toInsert isn’t defined. That’s my first challenge.

let toInsert = {
“firstName” : $w( ‘#name’ ).value,
“email” : $w( ‘#email’ ).value,
“phone” : $w( ‘#phone’ ).value,
“Sensors” : $w( ‘#sensors’ ).value,
“Additional Users” : $w( ‘#users’ ).value,
“Additional Data” : $w( ‘#additionalData’ ).value,
“Additional Actions” : $w( ‘#additionalActions’ ).value,
“Total Price” : totalPrice,
“Sensor Limit” : sensors,
“User Limit” : users + 4 ,
“Actions Limit” : (users + sensors + actions) * 10 ,
“Data Limits” : data + sensors


wixData.insert( "getAQuote02" , toInsert) 

The second challenge is that I now want to include some of the data in an email alert. I’ve set up the automation and that produces emails (two unless I remove the wixData code), but I can’t see how I can include the data in those emails. Is there a way of doing that?

If I remove the wixData.insert code I only get the line without data…

Perhaps you have also a dataset-connection ?
How can be something be inserted, if the code for this function is deactivated ???

Thanks. The first problem is solved now trying to work through the second. I would like to send a triggered email from the code. I have the triggered email set up ‘Quoteemail’. I have tried hard coding an email address in and using the email from the email input form (#email). I haven’t got anything to work (in the code below ContactId isn’t defined). I’ve tried to create a contact to facilitate the sending of an email, but I’m getting nowhere. Any ideas on what I’m doing wrong?



export function myBackendFunction() {
“firstName” : $w( ‘#name’ ).value,
“email” : $w( ‘#email’ ).value,



wixCrm.emailContact( "Quoteemail" , ContactId, { 

“variables” : {
“vfirstName” : $w( ‘#name’ ).value,
“vSensors” : $w( ‘#sensors’ ).value,
“vAdditionalUsers” : $w( ‘#users’ ).value,
“vAdditionalData” : $w( ‘#additionalData’ ).value,
“vIOPS” : $w( ‘#additionalActions’ ).value,
“vTotalPrice” : “Total Price” ,
“vUserLimit” : “User Limit” ,
“vIOPSLimit” : “Action Limit” ,
“vDataLimit” : “Data Limits”

I do not use triggered-emails, but i experimented once with triggered-emails.
Perhaps you will find some hints here…

1 Like

Thanks for your support Russian-dima. I’ve managed to figure it out with your help

Very good! A good programmer never gives up :wink:.

Good luck and happy coding in your further projects!