Hi @ givemeawhisky ,
I apologize for the delayed response. I didn’t get notification of your reply.
I am using the method explained in “sending triggered email to contacts”
I am not sending to the owner email of the website.
The strange this is this code was working few months ago and it stopped sending emails. I don’t recall if I made any changes to the code.
This is the website, I was referring to. https://www.utr.org.uk/home
If I use gandesk@mail.uc.edu, it was able to send triggered email. None of the other emails I tried didn’t work. gandesk@mail.uc.edu is not the owner email of the website.
Any help is truly appreciating. I really want this to be working asap.
In google chrome, I pressed ctrl + shift + J after loading https://www.utr.org.uk/home
after completing the questionnaire, I see “contactId does not match current session contact (401)” error mesage for any email while gandesk@mail.uc.edu says " triggered emails is sent".
Please let me know if you need any other details.
Here is the part of the code I created for sending the emails.
export function slide5a_click(event) {
console.log(customerObject);
console.log(customerobject2_final);
$w(‘#dataset1’).setFieldValues(customerObject);
$w(‘#dataset1’).setFieldValues(customerobject2_final);
$w(‘#dataset1’).save();
$w(‘#button34’).hide();
$w(‘#text22’).hide();
$w(‘#input1’).hide();
$w(‘#input2’).hide();
$w(‘#input3’).hide();
$w(‘#button17’).hide();
$w(‘#button35’).show();
wixCRM.createContact({
“firstName”: $w(“#input1”).value,
“emails”: [$w(“#input2”).value],
//“phones”: [$w(“#input3”).value],
“customField_DoUhaveUTR”: customerObject.DoUhaveUTR,
“customField_UTRpurpose”: customerObject.UTRpurpose,
“customField_DidUearn”: customerObject.DidUearn,
“customField_SubmittedUKtax”: customerObject.SubmittedUKtax,
“customField_self_Employed”: customerObject2.self_Employed,
“customField_cisWorker”: customerObject2.cisWorker,
“customField_businessPartner”: customerObject2.businessPartner,
“customField_company_Director”: customerObject2.company_Director,
“customField_propertyLandlord”: customerObject2.propertyLandlord,
“customField_investIncome10k”: customerObject2.investIncome10k,
“customField_earnOver100k”: customerObject2.earnOver100k
})
.then((contactId) => {
wixCRM.emailContact(“RJaNdVi”, contactId, {
“variables”: {
“name”: $w(“#input1”).value,
“DoUhaveUTR_”: DoUhaveUTR_,
“UTRpurpose_”: UTRpurpose_,
“DidUearn_”: DidUearn_,
“YouAreField_”: YouAreField_,
“SubmittedUKtax_”: SubmittedUKtax_
}
})
.then(() => {
console.log(“Triggered email sent”);
})
. catch ((err) => {
console.log(err);
});
});
}
Here is the complete code that is in the page.
import wixCRM from ‘wix-crm’;
import { sendToMailChimp } from ‘backend/mailChimp.jsw’;
//$w.onReady(() => {
//waitForLoading();
//});
//function waitForLoading() {
// setTimeout(() => {
// $w(‘#preloader’).hide(‘FadeOut’);
// }, 1500);
//}
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
var name = “”;
var DoUhaveUTR_ = “”;
var UTRpurpose_ = “”;
var DidUearn_ = “”;
var YouAreField_ = “”;
var SubmittedUKtax_ = “”;
//$w.onReady(function () {
// console.log(“alele”);
// //TODO: write your page related code here…
//});
let customerObject = { DoUhaveUTR: “”, UTRpurpose: “NA”, DidUearn: “”, SubmittedUKtax: “” }
let customerObject2 = { self_Employed: “NA”, cisWorker: “NA”, businessPartner: “NA”, company_Director: “NA”, propertyLandlord: “NA”, investIncome10k: “NA”, earnOver100k: “NA” }
let customerobject2_final = { YouAreField: “NA” }
export function slide0a_click(event) {
customerObject.DoUhaveUTR = “Yes”;
DoUhaveUTR_ = “Thanks for contacting us to obtain a UTR number!”;
$w(‘#slideshow1’).changeSlide(2);
$w('#columnStrip8').hide("fade");
$w('#columnStrip9').hide("fade");
$w('#columnStrip10').hide("fade");
$w('#columnStrip11').hide("fade");
$w('#columnStrip12').hide("fade");
$w('#columnStrip13').hide("fade");
$w('#columnStrip14').hide("fade");
$w('#columnStrip1').hide("fade");
$w('#columnStrip7').hide("fade");
$w('#text17').hide("fade");
$w('#anchorMenu1').collapse();
$w('#button8').hide("fade");
$w('#horizontalMenu1').hide("fade");
}
export function slide0b_click(event) {
customerObject.DoUhaveUTR = “Already Have One”;
//DoUneedUTR = “You mentioned that”;
$w(‘#slideshow1’).changeSlide(1);
$w(‘#textBox1’).hide();
$w(‘#button22’).show();
$w(‘#button23’).hide();
$w(‘#button9’).show();
$w(‘#button10’).show();
$w('#columnStrip8').hide("fade");
$w('#columnStrip9').hide("fade");
$w('#columnStrip10').hide("fade");
$w('#columnStrip11').hide("fade");
$w('#columnStrip12').hide("fade");
$w('#columnStrip13').hide("fade");
$w('#columnStrip14').hide("fade");
$w('#columnStrip1').hide("fade");
$w('#columnStrip7').hide("fade");
$w('#text17').hide("fade");
$w('#anchorMenu1').collapse();
$w('#button8').hide("fade");
$w('#horizontalMenu1').hide("fade");
}
export function button1_click(event) {
$w(‘#slideshow1’).changeSlide(0);
}
export function slide1a_click(event) {
customerObject.UTRpurpose = “Lost”;
UTRpurpose_ = “Find the instructions to retrive your Lost UTR Number:”;
$w(‘#slideshow1’).changeSlide(2);
}
export function slide1b_click(event) {
customerObject.UTRpurpose = “Replacement”;
UTRpurpose_ = “Find the instructions to Replace your UTR Number:”;
$w(‘#slideshow1’).changeSlide(2);
}
export function slide1c_click(event) {
customerObject.UTRpurpose = “Other”;
UTRpurpose_ = “You already have a UTR!”;
$w(‘#textBox1’).show();
$w(‘#button22’).hide();
$w(‘#button23’).show();
$w(‘#button9’).hide();
$w(‘#button10’).hide();
}
export function slide1d_click(event) {
$w(‘#slideshow1’).changeSlide(2);
}
export function button2_click(event) {
$w(‘#slideshow1’).changeSlide(0);
}
export function slide2a_click(event) {
customerObject.DidUearn = “Yes”;
$w(‘#slideshow1’).changeSlide(3);
DidUearn_ = “Instructions for a person earning more than 1000 Pounds:”
}
export function slide2b_click(event) {
customerObject.DidUearn = “No”;
$w(‘#slideshow1’).changeSlide(3);
DidUearn_ = “Instructions for a person earning less than 1000 Pounds:”
}
export function button3_click(event) {
$w(‘#slideshow1’).changeSlide(2);
}
var slide3a = 1;
export function slide3a_click(event) {
$w(‘#button28’).show();
if (slide3a === 0) {
$w(‘#button13’).style.backgroundColor = “#F16876”;
customerObject2.self_Employed = “NA”;
slide3a = 1;
} else {
$w(‘#button13’).style.backgroundColor = “#273B7B”;
customerObject2.self_Employed = “self_Employed”;
slide3a = 0;
}
}
var slide3b = 1;
export function slide3b_click(event) {
$w(‘#button28’).show();
if (slide3b === 0) {
$w(‘#button14’).style.backgroundColor = “#F16876”;
customerObject2.cisWorker = “NA”;
slide3b = 1;
} else {
$w(‘#button14’).style.backgroundColor = “#273B7B”;
customerObject2.cisWorker = “cisWorker”;
slide3b = 0;
}
}
var slide3c = 1;
export function slide3c_click(event) {
$w(‘#button28’).show();
if (slide3c === 0) {
$w(‘#button20’).style.backgroundColor = “#F16876”;
customerObject2.businessPartner = “NA”;
slide3c = 1;
} else {
$w(‘#button20’).style.backgroundColor = “#273B7B”;
customerObject2.businessPartner = “businessPartner”;
slide3c = 0;
}
}
var slide3d = 1;
export function slide3d_click(event) {
$w(‘#button28’).show();
if (slide3d === 0) {
$w(‘#button21’).style.backgroundColor = “#F16876”;
customerObject2.company_Director = “NA”;
slide3d = 1;
} else {
$w(‘#button21’).style.backgroundColor = “#273B7B”;
customerObject2.company_Director = “company_Director”;
slide3d = 0;
}
}
var slide3e = 1;
export function slide3e_click(event) {
$w(‘#button28’).show();
if (slide3e === 0) {
$w(‘#button24’).style.backgroundColor = “#F16876”;
customerObject2.propertyLandlord = “NA”;
slide3e = 1;
} else {
$w(‘#button24’).style.backgroundColor = “#273B7B”;
customerObject2.propertyLandlord = “propertyLandlord”;
slide3e = 0;
}
}
var slide3f = 1;
export function slide3f_click(event) {
$w(‘#button28’).show();
if (slide3f === 0) {
$w(‘#button25’).style.backgroundColor = “#F16876”;
customerObject2.investIncome10k = “NA”;
slide3f = 1;
} else {
$w(‘#button25’).style.backgroundColor = “#273B7B”;
customerObject2.investIncome10k = “investIncome10k”;
slide3f = 0;
}
}
var slide3g = 1;
export function slide3g_click(event) {
$w(‘#button28’).show();
if (slide3g === 0) {
$w(‘#button26’).style.backgroundColor = “#F16876”;
customerObject2.earnOver100k = “NA”;
slide3g = 1;
} else {
$w(‘#button26’).style.backgroundColor = “#273B7B”;
customerObject2.earnOver100k = “earnOver100k”;
slide3g = 0;
}
}
var slide3h = 1;
export function slide3h_click(event) {
$w(‘#button28’).show();
if (slide3h === 0) {
$w(‘#button27’).style.backgroundColor = “#F16876”;
slide3h = 1;
$w(‘#textBox2’).hide();
} else {
$w(‘#button27’).style.backgroundColor = “#273B7B”;
slide3h = 0;
$w(‘#textBox2’).show();
}
}
var slide3i = 1;
export function slide3i_click(event) {
$w(‘#slideshow1’).changeSlide(4);
customerobject2_final.YouAreField = customerObject2.self_Employed + “
” + customerObject2.company_Director + “
” + customerObject2.propertyLandlord + “
” + customerObject2.investIncome10k + “
” + customerObject2.earnOver100k + “
” + customerObject2.businessPartner + “
” + customerObject2.cisWorker;
}
export function button4_click(event) {
$w(‘#slideshow1’).changeSlide(3);
}
export function slide4a_click(event) {
customerObject.SubmittedUKtax = “Yes”;
$w(‘#slideshow1’).changeSlide(5);
SubmittedUKtax_ = “Instructions for a person who submitted UK tax:”
}
export function slide4b_click(event) {
customerObject.SubmittedUKtax = “No”;
$w(‘#slideshow1’).changeSlide(5);
SubmittedUKtax_ = “Instructions for a person who didn’t submit UK tax:”
}
export function button5_click(event) {
$w(‘#slideshow1’).changeSlide(4);
}
export function slide5a_click(event) {
console.log(customerObject);
console.log(customerobject2_final);
$w(‘#dataset1’).setFieldValues(customerObject);
$w(‘#dataset1’).setFieldValues(customerobject2_final);
$w(‘#dataset1’).save();
$w(‘#button34’).hide();
$w(‘#text22’).hide();
$w(‘#input1’).hide();
$w(‘#input2’).hide();
$w(‘#input3’).hide();
$w(‘#button17’).hide();
$w(‘#button35’).show();
wixCRM.createContact({
“firstName”: $w(“#input1”).value,
“emails”: [$w(“#input2”).value],
//“phones”: [$w(“#input3”).value],
“customField_DoUhaveUTR”: customerObject.DoUhaveUTR,
“customField_UTRpurpose”: customerObject.UTRpurpose,
“customField_DidUearn”: customerObject.DidUearn,
“customField_SubmittedUKtax”: customerObject.SubmittedUKtax,
“customField_self_Employed”: customerObject2.self_Employed,
“customField_cisWorker”: customerObject2.cisWorker,
“customField_businessPartner”: customerObject2.businessPartner,
“customField_company_Director”: customerObject2.company_Director,
“customField_propertyLandlord”: customerObject2.propertyLandlord,
“customField_investIncome10k”: customerObject2.investIncome10k,
“customField_earnOver100k”: customerObject2.earnOver100k
})
.then((contactId) => {
wixCRM.emailContact(“RJaNdVi”, contactId, {
“variables”: {
“name”: $w(“#input1”).value,
“DoUhaveUTR_”: DoUhaveUTR_,
“UTRpurpose_”: UTRpurpose_,
“DidUearn_”: DidUearn_,
“YouAreField_”: YouAreField_,
“SubmittedUKtax_”: SubmittedUKtax_
}
})
.then(() => {
console.log(“Triggered email sent”);
})
. catch ((err) => {
console.log(err);
});
});
}
export function dataset1_afterSave_1() {
// Only if user is subscribing
// Format data (field names must be those specified by MailChimp)
var data = {
“email_address”: $w(“#input2”).value,
“merge_fields”: {
“FNAME”: $w(“#input1”).value,
“PHONE”: $w(“#input3”).value,
“MMERGE3”: customerObject.DoUhaveUTR,
“MMERGE4”: customerObject.UTRpurpose,
“MMERGE5”: customerObject.DidUearn,
“MMERGE6”: customerObject.SubmittedUKtax,
“MMERGE7”: customerObject2.self_Employed,
“MMERGE8”: customerObject2.cisWorker,
“MMERGE9”: customerObject2.businessPartner,
“MMERGE10”: customerObject2.company_Director,
“MMERGE11”: customerObject2.propertyLandlord,
“MMERGE12”: customerObject2.investIncome10k,
“MMERGE13”: customerObject2.earnOver100k
},
“status”: “subscribed”
};
// Stringify into JSON format
data = JSON.stringify(data, ‘\t’);
// Process request
sendToMailChimp(data);
}