Submit to two datasets via one submit button

From what I have gathered this is possible through adding some custom JavaScript. However, I think it could be very useful to have for people who don’t know how to code.

Here’s what I am thinking:

Just after adding a dataset and connecting your button, have the ability to connect two databases simultaneously.

After connecting your buttons to several databases simply pick and choose the correct setting for you user inputs.

If you have a form asking a bunch of questions, connect the different inputs to which ever databases you would like to submit to.

For example;

If your form asks for: name, email address, contact number, product name, & for a product description. You may want the name, email address, & contact number to be added to a ‘Client’ database. Then for all of the input fields to be added to a ‘Product’ database. All of which is done via the one submit button.

This would require the ability to also add two datasets when connecting a user input.

Of course, there’s always the ability to add a two part submission form, however, if you require the same information in two databases you have to repeat certain user inputs which can be unprofessional.

Thank you for anybody who has taken their time to read this.

4 Likes

I need the same if you have already found the solution.
Thanks.

I, too, would like to know this!!!

just code it and stop messing around with the limited options available in the GUI…

import wixData from “wix-data”;

$w.onReady( function () {

//change button, dataset, fieldkey, input ids as necessary

$w('#submitButton1').onClick((event) => { 


    $w('#dataset1').setFieldValue('fieldKey1', $w('#input1').value); 
    $w('#dataset1').setFieldValue('fieldKey2', $w('#input2').value); 
    $w('#dataset1').setFieldValue('fieldKey3', $w('#input3').value); 
    $w('#dataset1').save(); 


   $w('#dataset2').setFieldValue('fieldKey1', $w('#input1').value); 
    $w('#dataset2').setFieldValue('fieldKey2', $w('#input2').value); 
    $w('#dataset2').setFieldValue('fieldKey3', $w('#input3').value); 
    $w('#dataset2').save(); 

})
})

4 Likes