Lead Lookup
Lead object in Salesforce represents a potential buyer.
Required fields:
- LastName (required by Salesforce)
- Company (required by Salesforce)
- Email (required by PowerSync)
- Magento Website (required by PowerSync)
If PersonAccounts are enabled in Salesforce org, Company field becomes optional
If person account record types have been enabled, and if the value of Company field is null, the lead converts to a person account.
Logic:
Primary goal is to find all Leads where "Email" field matches an email address of a Lead in Salesforce OR if a Lead exist where Magento ID field matches the Magento ID field value of a customer in Magento.
Valid matches:
- Email Address match
- Magento ID match (Email could be different)
If "Per Website" account sharing settings in Magento are turned on, this implies that Magento may have duplicate customers in Magento, but each of those duplicates has to belong to one Magento Website. With "Per Website" scope, in addition to "Email" field Magento also MUST match Magento Website in attempt to identify a match.
Valid matches:
- Email address match and Website match
- Magento ID match (Email and Website could be different)
- Email address match and Website value is empty
Duplicate Found
If duplicate Leads are found in Salesforce, Lead merge() should take place to ensure there are no duplicate Leads in Salesforce system