File tree 1 file changed +11
-0
lines changed
packages/app-store/salesforce/lib
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -800,6 +800,17 @@ export default class SalesforceCRMService implements CRM {
800
800
const conn = await this . conn ;
801
801
const emailDomain = email . split ( "@" ) [ 1 ] ;
802
802
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
803
814
const response = await conn . query (
804
815
`SELECT Id, Email, AccountId FROM Contact WHERE Email LIKE '%@${ emailDomain } ' AND AccountId != null`
805
816
) ;
You can’t perform that action at this time.
0 commit comments