"Add or create" when in import/sync in bulk

I’m facing an issue I’m not finding a way to solve…

When contacts are synced from email, I want them to create/link to a “company” using their email domain, matching to company domain. The problem is when syncing an email, it may create multiple contacts at the same time, and then the automation happens in batch. But this means that the solution I was trying (2 automations, one that tried to link an existing one, then checks a box that it searched for it, and other to create that triggers when that box is checked and it didn’t find one) doesn’t work. If no company exists, it create a new company for each contact as when it ran, there was no company existing.

What i suspect is happening:
3 contacts are created with the same company domain.
For each, it tries to link a company with existing domain.
All come back with nothing link
Automation 2 triggers to create a company for each of them. (even though they have the same company)

If each contact was processed separately (or the if-then logic was in one automation) then it would work. But right now it doesn’t. Has anyone done something like this and could help me out to find a solution?

Thanks a lot!!

What I haven’t tried yet:

  1. Scripting, although i suspect it might have a similar issue as all scripts run in parallel in batch?
  2. Letting it make duplicates, then running a de-duplication automation as well after.

It’ll possibly be solvable when the ‘upsert’ (create-or-update) functionality has been rolled out to all relevant services.

Any ideas for a current solution?

I’m not even sure if the upsert will work as it runs in bulk…

When upsert runs for a batch, you can choose the desired behaviour, if/when there are duplicates within the batch.

1 Like

Will try this with scripting on Monday. I’ll update here. Thanks Chris!

Solved with scripting!

Here’s how:
All actions in no-code scripts are in a loop to run for each entity in the batch. In scripting, you can script for something to happen once outside of the loop. So before anything else, it checks what companies need to be created and creates those. Then there’s a no-code action to update the company of the contact using filters of the website url. I tried using the new create-or-update, but was unsuccessful. This works quite nicely now though.