Skip to content

Commit 2444598

Browse files
Fuzzy search account website, fallback to contacts (#17989)
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
1 parent 6eadade commit 2444598

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/app-store/salesforce/lib/CrmService.ts

+11
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,17 @@ export default class SalesforceCRMService implements CRM {
800800
const conn = await this.conn;
801801
const emailDomain = email.split("@")[1];
802802

803+
// First check if an account has the same website as the email domain of the attendee
804+
const accountQuery = await conn.query(
805+
`SELECT Id, Website FROM Account WHERE Website LIKE '%${emailDomain}%'`
806+
);
807+
808+
if (accountQuery.records.length > 0) {
809+
const account = accountQuery.records[0] as { Id: string };
810+
return account.Id;
811+
}
812+
813+
// Fallback to querying which account the majority of contacts are under
803814
const response = await conn.query(
804815
`SELECT Id, Email, AccountId FROM Contact WHERE Email LIKE '%@${emailDomain}' AND AccountId != null`
805816
);

0 commit comments

Comments
 (0)