Scheduling infrastructure for absolutely everyone.
fix: Salesforce ownership query (#20405)
Joe Au-Yeung7f5534b340b6
diff --git a/packages/app-store/salesforce/lib/CrmService.test.ts b/packages/app-store/salesforce/lib/CrmService.test.tsindex e8a2400a63e..04103843305 100644--- a/packages/app-store/salesforce/lib/CrmService.test.ts+++ b/packages/app-store/salesforce/lib/CrmService.test.ts@@ -572,4 +572,19 @@ describe("SalesforceCRMService", () => {);});});++ describe("getAccountBasedOnEmailDomainOfContacts", () => {+ it("should return the account ID based on email domain", async () => {+ const querySpy = vi.spyOn(mockConnection, "query");+ querySpy.mockResolvedValueOnce(accountQueryResponse);++ await service.getAccountBasedOnEmailDomainOfContacts("[email protected]");+ expect(querySpy).toHaveBeenNthCalledWith(+ 1,+ `SELECT Id, OwnerId, Owner.Email, Website FROM Account WHERE Website IN (${service.getAllPossibleAccountWebsiteFromEmailDomain(+ "example.com"+ )}) LIMIT 1`+ );+ });+ });});diff --git a/packages/app-store/salesforce/lib/CrmService.ts b/packages/app-store/salesforce/lib/CrmService.tsindex 8f22c3a2fc9..237fa8ab868 100644--- a/packages/app-store/salesforce/lib/CrmService.ts+++ b/packages/app-store/salesforce/lib/CrmService.ts@@ -941,14 +941,14 @@ export default class SalesforceCRMService implements CRM {return accountId;}- private async getAccountBasedOnEmailDomainOfContacts(email: string) {+ public async getAccountBasedOnEmailDomainOfContacts(email: string) {const conn = await this.conn;const emailDomain = email.split("@")[1];const log = logger.getSubLogger({ prefix: [`[getAccountBasedOnEmailDomainOfContacts]:${email}`] });log.info("Querying first account matching email domain", safeStringify({ emailDomain }));// First check if an account has the same website as the email domain of the attendeeconst accountQuery = await conn.query(- `SELECT Id, OwnerId, Owner.Email, Owner.Website FROM Account WHERE Website IN (${this.getAllPossibleAccountWebsiteFromEmailDomain(+ `SELECT Id, OwnerId, Owner.Email, Website FROM Account WHERE Website IN (${this.getAllPossibleAccountWebsiteFromEmailDomain(emailDomain)}) LIMIT 1`);