@@ -890,11 +890,13 @@ export default class SalesforceCRMService implements CRM {
890
890
log . info ( "getAccountIdBasedOnEmailDomainOfContacts" , safeStringify ( { email, emailDomain } ) ) ;
891
891
// First check if an account has the same website as the email domain of the attendee
892
892
const accountQuery = await conn . query (
893
- `SELECT Id, Website FROM Account WHERE Website LIKE '%${ emailDomain } %' LIMIT 1`
893
+ `SELECT Id, Website FROM Account WHERE Website IN ('${ emailDomain } ', 'www.${ emailDomain } ',
894
+ 'http://www.${ emailDomain } ', 'http://${ emailDomain } ',
895
+ 'https://www.${ emailDomain } ', 'https://${ emailDomain } ') LIMIT 1`
894
896
) ;
895
-
896
897
if ( accountQuery . records . length > 0 ) {
897
898
const account = accountQuery . records [ 0 ] as { Id : string } ;
899
+ log . info ( "Found account based on email domain" , safeStringify ( { accountId : account . Id } ) ) ;
898
900
return account . Id ;
899
901
}
900
902
@@ -903,7 +905,15 @@ export default class SalesforceCRMService implements CRM {
903
905
`SELECT Id, Email, AccountId FROM Contact WHERE Email LIKE '%@${ emailDomain } ' AND AccountId != null`
904
906
) ;
905
907
906
- return this . getDominantAccountId ( response . records as { AccountId : string } [ ] ) ;
908
+ const accountId = this . getDominantAccountId ( response . records as { AccountId : string } [ ] ) ;
909
+
910
+ if ( accountId ) {
911
+ log . info ( "Found account based on other contacts" , safeStringify ( { accountId } ) ) ;
912
+ } else {
913
+ log . info ( "No account found" ) ;
914
+ }
915
+
916
+ return accountId ;
907
917
}
908
918
909
919
private async getAccountBasedOnEmailDomainOfContacts ( email : string ) {
0 commit comments