Hi
I’m trying to create a triggered email with a simple Name and email form but nothing happens
Here is the code I use on my page
What am I doing wrong?
import wixCRM from 'wix-crm';
import wixUsers from 'wix-users';
$w.onReady(function() {
$w('#button5').onClick(function() {
wixCRM.createContact({
"firstName": $w('#input2').value,
"lastName": "Navon",
"emails": [$w('#input1').value],
"phones": ["0549709128"]
})
.then((id) => {
wixCRM.emailContact('test', id, {
variables: {
Name: $w('#input2').value,
email: $w('#input1').value
}})
.catch((err)=>{
$w('#text26').text = "error sending email:" + err;
});
})
.catch((err)=>{
$w('#text26').text = "error creating contact:" + err;
});
});
});
Using a simple Wix form with Corvid Code creates some issues. You likely won't be able to connect it to data and may have issues connecting to a variable. You might want to build a form from scratch. It only takes about 10 minutes.
For more information, see the docs on Triggered Emails.
Once you create a contact, you can't then create again. Therefore, no email would be triggered. It works once for each contact created.
Try closing the onready function before the button.onclick function is defined.
i tried again
it worked once and stopped working
you can take a look here
https://bestsiteisrael.wixsite.com/content-test/reg
What happens? Do you get anything in the console?