Wix Forms - Sending multiple rows to same columns

Hello everyone,

I am currently working on a Wix form (#form1) that collects shipping information such as first name (#input3), last name (#input2), email (#input1), company name (#input3), ship from (#addressInput3), ship to (#addressInput1), delivery option (#dropdown1), and details about the items being shipped such as quantity, weight, length, width, and depth of up to three items (#input4, #input5, #input6, #input7, #input8, #input10, #input11, #input12, #input13, #input14, #input15, #input16, #input17).
I have a database collection called “delivery-form” that includes fields for weight, quantity, email, lastName, firstName, companyName, deliveryType, depth, length, and width.

However, I am struggling with submitting the form data to the database in a format where the quantities, weight, length, width, and depth are all in the same column.

I would greatly appreciate any help or guidance on how to properly format the form data and submission button (#button1) to ensure the data is properly collected in the database. Thank you in advance for any assistance you can provide!

I wouldn’t recommend this because by concatenating your data into one column, it will be more difficult to sort and query in the future. In addition you will have to store everything as a string separated by commas so to do any future calculations you would need to deal with this when you query.

However, if this is required for your use case all you have to do is define the column name in your collection and then on insert make sure to concatenate the data prior to the insert.

let newVal = val1 + "," + val2....etc etc.  

"my_field": newVal 

See the link for the full code snippet on how to inset values to a collection

The issues with having my quantity, length, width, weight and depth columns not in the same row is that my form allowa multiple entries as it’s a parcel delivery form, so I could potientially have 50+ columns

Could I have the form send multiple entries at once. E.g. company name, email, send to, ship sending multiple times with the same valuea and the parcel dimensions sending with them on different rows?

You can create as many inserts to your collection or collections as you like. There is no restriction, you will just have to code it based on the link I provided explaining how to insert data to your collection.

This doesn’t seem to be working, any advice would be great. Thanks in advance

export function button1_click(event, $w) {
let toInsert1 = {
“weight”: $w(“#input5”).value,
“quantity”: $w(“#input4”).value,
“email”: $w(“#input1”).value,
“shipTo”: $w(“#addressInput1”).value,
“lastName”: $w(“#input2”).value,
“firstName”: $w(“#input3”).value,
“shipFrom”: $w(“#addressInput3”).value,
“companyName”: $w(“#input5”).value,
“depth”: $w(“#input8”).value,
“length”: $w(“#input6”).value,
“width”: $w(“#input7”).value

let toInsert2 = {
“weight”: $w(“#input11”).value,
“quantity”: $w(“#input10”).value,
“email”: $w(“#input1”).value,
“shipTo”: $w(“#addressInput1”).value,
“lastName”: $w(“#input2”).value,
“firstName”: $w(“#input3”).value,
“shipFrom”: $w(“#addressInput3”).value,
“companyName”: $w(“#input5”).value,
“depth”: $w(“#input14”).value,
“length”: $w(“#input12”).value,
“width”: $w(“#input13”).value

wixData.bulkInsert(“delivery-form”, [toInsert1, toInsert2])
.then((results) => {
let inserted = results.inserted; // 2
let insertedIds = results.insertedItemIds; // see below
let updated = results.updated; // 0
let skipped = results.skipped; // 0
let errors = results.errors; // []
.catch((err) => {
let errorMsg = err;

When you say “not working” what do you mean?

The data is not sending to my collection. I have tried recreating the form using a custom form but I’m still having no luck

The data does not send to my collection. I’ve have recreated the Wix form in a custom form and still getting no where. Does each field need to be connected to the value in the collection?

I would try with hardcoded data first on the insert to test that your inset code is correct before you hook this up to a form.

I would double check things like your collection id and making sure all those column names are correct.

Once you are sure you can insert test data, then hook up to your form values