Hi, there, I was making a function so it makes a triggered email when you submit your thing, there’s no errors showing up in the page code, but i’m not receiving the email. #TriggeredEmails
This is the code:
wixCrm.createContact({
“firstName”: $w(‘#input1’).value,
“emails”: $w(“#input2”).value
})
.then((contactId) => {
wixCrm.emailContact(“REDACTED”, contactId, {
“variables”: {
“question6”: $w(“#richTextBox6”).value,
“question8”: $w(“#richTextBox8”).value,
“name”: $w(“#input1”).value,
“question10”: $w(“#richTextBox10”).value,
“question2”: $w(“#richTextBox2”).value,
“question7”: $w(“#richTextBox7”).value,
“question3”: $w(“#richTextBox3”).value,
“question4”: $w(“#richTextBox4”).value,
“question5”: $w(“#richTextBox5”).value,
“question9”: $w(“#richTextBox11”).value,
“question1”: $w(“#richTextBox1”).value
}
})
})
Easiest solution is to do away with the code, and use the Wix Automations feature. So much easier and requires no code.
will it work for form submissions?
Oh my god youre a life saver thx so much
As Brett says, just use the Wix Automations as much easier to do and without code.
However, your code should look something like this:
import wixCRM from 'wix-crm';
$w.onReady(function () {
});
export function submitButton_click(event) {
wixCRM.createContact({
"firstName": $w('#input1').value,
"emails": [$w("#input2").value]
})
.then((contactId) => {
wixCRM.emailContact("REDACTED", contactId, { //REDACTED is your triggered email id
"variables": {
"question6": $w("#richTextBox6").value,
"question8": $w("#richTextBox8").value,
"name": $w("#input1").value,
"question10": $w("#richTextBox10").value,
"question2": $w("#richTextBox2").value,
"question7": $w("#richTextBox7").value,
"question3": $w("#richTextBox3").value,
"question4": $w("#richTextBox4").value,
"question5": $w("#richTextBox5").value,
"question9": $w("#richTextBox11").value,
"question1": $w("#richTextBox1").value
}
})
.then(() => {
// do something after the email was sent
})
.catch((err) => {
// handle the error if the email wasn't sent
});
});
}
Hi
Can i still receive automation while test on unpublished site?