Skip to content

Commit

Permalink
Adds permission ids
Browse files Browse the repository at this point in the history
  • Loading branch information
vmesel committed Dec 19, 2023
1 parent 40eb302 commit 5a65245
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion target_salesforce_v3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.api_version = self.config.get("api_version", "55.0").replace("v", "")

@property
def permission_set_ids(self):
params = {"q": "SELECT Id FROM PermissionSet"}
response = self.request_api("GET", endpoint="query", params=params, headers={"Content-Type": "application/json"})
return [r["Id"] for r in response.json()["records"]]

@property
def http_headers(self) -> dict:
"""Return the http headers needed."""
Expand Down Expand Up @@ -380,7 +386,7 @@ def add_custom_field(self,cf,label=None):
# But then, we need to add the permissions to the Task sObject
# So we change it back again from `Activity` -> `Task`
sobject = 'Task'
for permission_set_id in getattr(self, "permission_set_ids", []):
for permission_set_id in self.permission_set_ids:
self.update_field_permissions(permission_set_id, sobject_type=sobject, field_name=f"{sobject}.{cf}")

def update_field_permissions(self,permission_set_id, sobject_type, field_name):
Expand Down
3 changes: 3 additions & 0 deletions target_salesforce_v3/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def preprocess_record(self, record: dict, context: dict):
if isinstance(record.get("campaigns"), str):
record["campaigns"] = json.loads(record.get("campaigns"))

if record.get("company") and not record.get("company_name"):
record["company_name"] = record["company"]

record = self.validate_input(record)

# Handles creation/update of Leads and Contacts
Expand Down

0 comments on commit 5a65245

Please sign in to comment.