@jonatandor35 Thanks, I know it is not perfect but at least the multiple export functions are working.
So if I understand the point 3, I should delete this part of code:
$w.onReady( function ()
{ $w(" #dataset1 ").onAfterSave(sendFormData); });
function sendFormData() {
const subject = Nouveau lead ${$w("#input1").value}
;
const body = Données du formulaire : ${$w("#input2").value} ${$w("#input1").value} ${$w("#input5").value} ${$w("#input6").value}
;
sendEmail(subject, body)
.then(response => console.log(response));
}
After deleting it, I run another test and:

- still the last page inputs (Name, First Name, Postcode, Phone) are not showing in the database board.
How can I link the values typed by the visitor to the database?
- Also, the email I receive does not contain any datas:

Someting must be wrong in the code:
$w(“#button24”).onClick(event => {
let emailEmailData = {info1: toSave.maisonIndividuelle, info2: toSave.pieceAIsoler, info3: toSave.foyer, info4: toSave.revenuAnnuel, info5: toSave.maisonIndividuelle}
wixData.save(“OneClickForm”, toSave)
.then(() => sendEmail(emailEmailData))
.then(() => wixLocation.to(“/formulaire-valide”));;
)
- Should I replace “emailEmailData” with something?
Here is the better looking code:
FRONTEND:
import wixCRM from ‘wix-crm’;
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
import {sendEmail} from ‘backend/email’;
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady( function () {
});
//clicked buttons datas configuration
let userId = wixUsers.currentUser.id;
$w.onReady(() => {
let toSave = {_id: userId};
$w(“#button3, #button4, #button5, #button6, #button7, #button8, #button9, #button10, #button11, #button12, #button13, #button14, #button15, #button16, #button17, #button18, #button19, #button20, #button21, #button22, #button23”).onClick(event => {
switch (event.target.id){
case “button3”:
toSave.maisonIndividuelle = “oui”;
$w(‘#group4’).hide();
$w(‘#group5’).show();
break ;
case “button4”:
toSave.maisonIndividuelle = “non”;
break ;
case “button5”:
toSave.pieceAIsoler = “Combles et grenier”;
$w(‘#group5’).hide();
$w(‘#group6’).show();
break ;
case “button6”:
toSave.pieceAIsoler = “Sous-sol et cave”;
$w(‘#group5’).hide();
$w(‘#group6’).show();
break ;
case “button7”:
toSave.pieceAIsoler = “Garage”;
$w(‘#group5’).hide();
$w(‘#group6’).show();
break ;
case “button8”:
toSave.pieceAIsoler = “Toute ma maison”;
$w(‘#group5’).hide();
$w(‘#group6’).show();
break ;
case “button9”:
toSave.foyer = “1”;
$w(‘#group6’).hide();
$w(‘#group7’).show();
break ;
case “button10”:
toSave.foyer = “2”;
$w(‘#group6’).hide();
$w(‘#group7’).show();
break ;
case “button11”:
toSave.foyer = “3”;
$w(‘#group6’).hide();
$w(‘#group7’).show();
break ;
case “button12”:
toSave.foyer = “4”;
$w(‘#group6’).hide();
$w(‘#group7’).show();
break ;
case “button13”:
toSave.foyer = “5 et +”;
$w(‘#group6’).hide();
$w(‘#group7’).show();
break ;
case “button14”:
toSave.revenuAnnuel = “- de 19 074€”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button15”:
toSave.revenuAnnuel = “19 074€-27 896€”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button16”:
toSave.revenuAnnuel = “27 896€-33 547€”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button17”:
toSave.revenuAnnuel = “33 547€-39 192€”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button18”:
toSave.revenuAnnuel = “39 192€-44 860”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button19”:
toSave.revenuAnnuel = “+ de 44 860€”;
$w(‘#group7’).hide();
$w(‘#group8’).show();
break ;
case “button20”:
toSave.m2 = “-50m2”;
$w(‘#group8’).hide();
$w(‘#group9’).show();
break ;
case “button21”:
toSave.m2 = “50-100m2”;
$w(‘#group8’).hide();
$w(‘#group9’).show();
break ;
case “button22”:
toSave.m2 = “100-200m2”;
$w(‘#group8’).hide();
$w(‘#group9’).show();
break ;
case “button23”:
toSave.m2 = “+200m2”;
$w(‘#group8’).hide();
$w(‘#group9’).show();
break ;
}
})
//email notification configuration
$w(“#button24”).onClick(event => {
let emailEmailData = {info1: toSave.maisonIndividuelle, info2: toSave.pieceAIsoler, info3: toSave.foyer, info4: toSave.revenuAnnuel, info5: toSave.maisonIndividuelle}
wixData.save(“OneClickForm”, toSave)
.then(() => sendEmail(emailEmailData))
.then(() => wixLocation.to(“/formulaire-valide”));
})
})
BACKEND:
backend email.jsw:
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “sendgridAPIthativehidden”;
const sender = “myemail@address.com”;
const recipient = “myemail@address.com”;
return sendWithService(key, sender, recipient, subject, body); }
backend sendGrid.js:
import {fetch} from ‘wix-fetch’;
export function sendWithService(key, sender, recipient, subject, body) {
const url = “https://api.sendgrid.com/api/mail.send.json”;
const headers = { “Authorization”: "Bearer " + key, “Content-Type”: “application/x-www-form-urlencoded” };
const data = from =${sender}&to=${recipient}&subject=${subject}&text=${body}
;
const request = { “method”: “post”, “headers”: headers, “body”: data };
return fetch(url, request) .then(response => response.json()); }