Skip to content

Commit

Permalink
Merge pull request #6 from hotgluexyz/fix/errorLogs
Browse files Browse the repository at this point in the history
fixed external ids
  • Loading branch information
hsyyid authored Jun 2, 2022
2 parents 4720c79 + 812f15d commit 500f55d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions target_salesforce/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,13 @@ def upload_target(client, payload_file, sobject):
LOGGER.info(f"Found {fname}, processing...")
payload = load_json(payload_file)

external_id = [f["name"] for f in sobject['fields'] if f['externalId']]
external_id = external_id[0] if external_id else None
external_ids = [f["name"] for f in sobject['fields'] if f['externalId']]

LOGGER.info(f"Uploading {len(payload)} {sobject['name']}(s) to SalesForce")
for item in payload:
if external_id in item.keys():
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)
rest = Rest(client)
query = f"SELECT Id, {external_id} FROM {sobject['name']} WHERE {external_id} = '{item.get(external_id)}' AND IsDeleted=false"
Expand All @@ -334,7 +335,7 @@ def upload_target(client, payload_file, sobject):
LOGGER.warning(f"{sobject['name']} do not have a valid Salesforce Sobject name.")
elif res.status_code==400:
LOGGER.warning(f"{payload} invalid payload: {res.json()[0].get('message')}")
elif res.status_code!=200:
elif res.status_code>300:
LOGGER.warning(f"{payload} invalid payload.")
continue
payload_str = json.dumps(item)
Expand Down

0 comments on commit 500f55d

Please sign in to comment.