top of page

Forum Comments

Error retrieving WixEvent
In Coding with Velo
Send email attachment to a contact via Wix email
In Velo Pro Discussion
wixData.aggregate Performance
In Velo Pro Discussion
Guy Tadmor
Mar 07, 2023
Thanks !!!
Help on authentication.register from wix-members-backend
In Coding with Velo
Help on authentication.register from wix-members-backend
In Coding with Velo
Triggered Email Issue for Custom Price Quote Form
In Velo Pro Discussion
Guy Tadmor
Dec 04, 2022
I believe that if you use backend code you will not have issues with the cache as in the page code the API send the email only for the current contact. Here is the code: Page code: import { createMyContact } from 'backend/myContacts.jsw' /** * Adds an event handler that runs when the element is clicked. [Read more](https://www.wix.com/corvid/reference/$w.ClickableMixin.html#onClick) * @param {$w.MouseEvent} event */ export async function button1_click(event) { // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4 // Add your code for this event here: let fname = $w("#inputFname").value; let lname = $w("#inputLname").value; let email = $w("#inputEmail").value; let phone = $w("#inputPhone").value; try { let response = await createMyContact(fname, lname, email, phone); } catch (err) { console.log(err); } } Backend code in myCotnacts.jsw: /********* .jsw file ********* Backend .jsw files contain functions that run on the server side but can be called from page code and frontend files. Use backend functions to keep code private and hidden from a user's browser. More info: https://support.wix.com/en/article/velo-web-modules-calling-backend-code-from-the-frontend **********/ import { contacts } from 'wix-crm-backend'; export async function createMyContact(fname, lname, email, phone) { // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4 // Add your code for this event here: return new Promise((resolve, reject) => { const contactInfo = { name: { first: fname, last: lname }, emails: [{ email: email, }], phones: [{ tag: "MOBILE", phone: phone, primary: true }] }; // when the email/phone given exists (can be only one of them), the mobile phone or email is added to the same contact. contacts.appendOrCreateContact(contactInfo) .then((resolvedContact) => { console.log(JSON.stringify(resolvedContact)); // TODO add fname and lname sendEmail(resolvedContact.contactId, fname, lname,'TP21do9'); resolve(resolvedContact.contactId) }) .catch((error) => { console.error("createContact error = " + JSON.stringify(error)); if (error.details.applicationError.code == "DUPLICATE_CONTACT_EXISTS") { console.log("duplicate contact"); } reject(error); }); }) } import { triggeredEmails } from 'wix-crm-backend'; function sendEmail(contactId, fname, lname,emailCode) { triggeredEmails.emailContact(emailCode, contactId, { variables: { fname: fname, lname: lname } }) .then(() => { console.log('Email was sent to contact'); }) .catch((error) => { console.error("trigger Email error " + error); }); }
Triggered Email Issue for Custom Price Quote Form
In Velo Pro Discussion
Guy Tadmor
Dec 03, 2022
What kind of issues do u have?
Routers Conflicts???[Solved]
In Velo Pro Discussion

Guy Tadmor

More actions
bottom of page