Skip to content

Commit

Permalink
HGI-6745: get linked object ref
Browse files Browse the repository at this point in the history
  • Loading branch information
butkeraites-hotglue authored and hsyyid committed Dec 12, 2024
1 parent 7cb6ff1 commit a95debe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions target_salesforce_v3/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,18 @@ def link_attachment_to_object(self, file_id, linked_object_id):
else:
raise Exception(f"Failed while trying to link file {file_id} and object {linked_object_id} because ContentDocumentId was not found")

if isinstance(linked_object_id, dict):
# they're using an external id, we need to look it up
link = list(linked_object_id.keys())[0]
sobject, external_id = link.split("/")
params = {"q": f"SELECT Id FROM {sobject} WHERE {external_id} = '{linked_object_id[link]}'"}
link_obj = self.request_api("GET", endpoint=content_endpoint, params=params)
link_obj = link_obj.json()
if link_obj.get("records"):
linked_object_id = link_obj['records'][0]['Id']
else:
raise Exception(f"Could not find matching {sobject} with {external_id} = '{linked_object_id[link]}'")

endpoint = "sobjects/ContentDocumentLink"
record = {
"ContentDocumentId": content_document_id,
Expand Down

0 comments on commit a95debe

Please sign in to comment.