Skip to content

Commit

Permalink
Merge pull request #7 from hotgluexyz/fix/multipleExtId
Browse files Browse the repository at this point in the history
allow multiple external ids
  • Loading branch information
hsyyid authored Aug 12, 2022
2 parents 500f55d + 88949fe commit 882741a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='target-salesforce',
version='1.0.5',
version='1.0.6',
description='hotglue target for exporting data to Salesforce API',
author='hotglue',
url='https://hotglue.xyz',
Expand Down
17 changes: 10 additions & 7 deletions target_salesforce/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,17 @@ def upload_target(client, payload_file, sobject):
for item in payload:
external_id = [i for i in item.keys() if i in external_ids]
if external_id:
external_id = external_id[0]
item = generate_ids(client, item)
update_item = item.copy()
update_item = generate_ids(client, update_item)
rest = Rest(client)
query = f"SELECT Id, {external_id} FROM {sobject['name']} WHERE {external_id} = '{item.get(external_id)}' AND IsDeleted=false"
params = {"q": query}
url = "{}/services/data/v41.0/queryAll".format(client.instance_url)
headers = client._get_standard_headers()
res = next(rest._sync_records(url, headers, params), False)
for eid in external_id:
query = f"SELECT Id, {eid} FROM {sobject['name']} WHERE {eid} = '{update_item.get(eid)}' AND IsDeleted=false"
params = {"q": query}
url = "{}/services/data/v41.0/queryAll".format(client.instance_url)
headers = client._get_standard_headers()
res = next(rest._sync_records(url, headers, params), False)
if res:
break
if res:
payload_str = json.dumps(item)
endpoint = "/".join(res['attributes']['url'].split("/")[4:])
Expand Down

0 comments on commit 882741a

Please sign in to comment.