Hi,
I have two forms set up on my site and I am trying to set up email notifications on submission for both. I set up one with no problem and it is working great, but the other is not.
Do I need to set up additional backend modules for the second form. Both forms can be sent from and to the same email addresses.
Here is the page code for the first, which works:
import {
sendEmail, sendEmailWithRecipient
}
from ‘backend/email’;
$w.onReady(function () {
$w(“#dataset2”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = Removal Permit Form Submission From ${$w("#input1").value}
;
const body = New Removal Permit Form From ${$w("#input1").value} \rFull Name: ${$w("#input1").value} \rAddress: ${$w("#input2").value} \rPhone: ${$w("#input3").value} \rEmail Address: ${$w("#input4").value} \rApplication Date: ${$w("#datePicker1").value} \rLocation of Tree: ${$w("#input5").value} \rContractor: ${$w("#input6").value} \rInspection Date: ${$w("#datePicker2").value} \rInspection Comments: ${$w("#textBox1").value} \rDisposition: ${$w("#textBox2").value}
;
const recipient = $w(“#input4”).value;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
}
And here is the page code for the second, which doesn’t work:
import {
sendEmail, sendEmailWithRecipient
}
from ‘backend/email’;
$w.onReady(function () {
$w(“#dataset2”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = Removal Permit Form Submission From ${$w("#input1").value}
;
const body = New Removal Permit Form From ${$w("#input1").value} \rFull Name: ${$w("#input1").value} \rAddress: ${$w("#input2").value} \rPhone: ${$w("#input3").value} \rEmail Address: ${$w("#input4").value} \rApplication Date: ${$w("#datePicker1").value} \rLocation of Tree: ${$w("#input5").value} \rContractor: ${$w("#input6").value} \rInspection Date: ${$w("#datePicker2").value} \rInspection Comments: ${$w("#textBox1").value} \rDisposition: ${$w("#textBox2").value}
;
const recipient = $w(“#input4”).value;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
}
Am I missing something obvious?