Skip to content

Commit

Permalink
lookup using all email fields in fallback sink
Browse files Browse the repository at this point in the history
  • Loading branch information
keyn4 committed Apr 11, 2024
1 parent 4ab6543 commit 7c63b9c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions target_salesforce_v3/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,10 @@ def preprocess_record(self, record, context):
return {}
record["object_type"] = object_type

# Try to find object instance
if record.get("Email"):
email_to_check = record.get("Email")

# Try to find object instance using email
email_fields = ["Email", "npe01__AlternateEmail__c", "npe01__HomeEmail__c", "npe01__Preferred_Email__c", "npe01__WorkEmail__c"]
email_values = [record.get(email_field) for email_field in email_fields if record.get(email_field)]
for email_to_check in email_values:
# Escape special characters on email
for char in ["+", "-"]:
if char in email_to_check:
Expand All @@ -759,7 +759,8 @@ def preprocess_record(self, record, context):

if req.json().get("searchRecords"):
record["Id"] = req.json()["searchRecords"][0]["Id"]

break

return record

def upsert_record(self, record, context):
Expand Down

0 comments on commit 7c63b9c

Please sign in to comment.