From a9e7ef3ccdf516ba50bef5ac86b4bfbd25a7f924 Mon Sep 17 00:00:00 2001 From: Key Date: Tue, 22 Oct 2024 18:24:45 -0500 Subject: [PATCH] clean empty datetime fields in fallback sink --- target_salesforce_v3/sinks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target_salesforce_v3/sinks.py b/target_salesforce_v3/sinks.py index 2df4b25..daf0c6d 100644 --- a/target_salesforce_v3/sinks.py +++ b/target_salesforce_v3/sinks.py @@ -882,6 +882,13 @@ def preprocess_record(self, record, context): except MissingObjectInSalesforceError: self.logger.info("Skipping record, because it was not found on Salesforce.") return {} + + # keep only available fields and that are creatable or updatable + record = {k:v for k,v in record.items() if fields.get(k) and (fields[k]["createable"] or fields[k]["updateable"])} + # clean empty date fields to avoid salesforce parsing error + record = {k:v for k,v in record.items() if fields[k].get("type") not in ["date", "datetime"] or (fields[k].get("type") in ["date", "datetime"] and v)} + + # add object_type record["object_type"] = object_type # If lookup_fields dict exist in config use it to check if the record exists in Salesforce