Multiple Form Submission Email Notifications

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?

Sorry, I pasted the same code twice. Here is the code for the second form:

import {
sendEmail, sendEmailWithRecipient
}
from ‘backend/email’;

$w.onReady(function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});

function sendFormData() {
const subject = New hazardous tree submission from ${$w("#Name").value};
const body = New hazardous tree form submission from: ${$w("#Name").value} \rFull Name: ${$w("#Name").value} \rHouse Number: ${$w("#House").value} \rStreet Name: ${$w("#Street").value} \rPhone: ${$w("#Phone").value} \rEmail: ${$w("#Email").value} \rTree Issue: ${$w("#group1, #group2, #group3, #group4, #group5, #group6").value} \rDescribe: ${$w("#textBox1").value};
const recipient = $w(“#Email”).value;

sendEmailWithRecipient(subject, body, recipient) 
	.then(response => console.log(response)); 

sendEmail(subject, body) 
	.then(response => console.log(response)); 

}

Hi Jenette,

The code looks ok.
Try adding a button to the page, and in its onClick event call sendFormData();
Check your console to see if any errors are thrown.