Scheduling infrastructure for absolutely everyone.
fix: Salesforce if contact was created don't create new lead as well (#17299)
Joe Au-Yeung62d162f001e2
diff --git a/packages/app-store/salesforce/lib/CrmService.ts b/packages/app-store/salesforce/lib/CrmService.tsindex 2b5a474529d..7b78af01b32 100644--- a/packages/app-store/salesforce/lib/CrmService.ts+++ b/packages/app-store/salesforce/lib/CrmService.ts@@ -406,6 +406,8 @@ export default class SalesforceCRMService implements CRM {const accountId = this.getDominantAccountId(response.records as { AccountId: string }[]);+ let contactCreated = false;+if (accountId && appOptions.createNewContactUnderAccount) {// First see if the contact already exists and connect it to the accountconst userQuery = await conn.query(`SELECT Id, Email FROM Contact WHERE Email = '${attendee.email}'`);@@ -432,11 +434,12 @@ export default class SalesforceCRMService implements CRM {.then((result) => {if (result.success) {createdContacts.push({ id: result.id, email: attendee.email });+ contactCreated = true;}});}- if (appOptions.createLeadIfAccountNull) {+ if (!accountId && appOptions.createLeadIfAccountNull && !contactCreated) {// Check to see if the lead exists alreadyconst leadQuery = await conn.query(`SELECT Id, Email FROM Lead WHERE Email = '${attendee.email}'`);if (leadQuery.records.length) {