Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup using all email fields in fallback sink #14

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading