Error: item can not be added to more than one

Hi,

I have an automation that links an order to a campaign when the product + contact + date range matches.

An order can only be linked to one campaign.

When the product ID in the campaign is updated, the system searches for orders to link.

When all product ID’s are updated at the same time in the campaigns of a contact, I get this error in the automation that wants to link the order.

image

Which I can understand, since the order can only be linked to one campaign.

But the problem is that currently the order is linked to none of the campaigns because of this error.

How can I achieve that the order will be linked to one? I prefer that the order gets linked to the last campaign (is the example above February 24) but that’s not a hard requirement.

Thanks!

As a workaround I’ve created an extra many - many relation between campaign and order. Step 1 is that I link orders to all possible campaigns, step 2 is that I decide in the order to which (one) campaign it actually needs to be linked.

Feels a bit heavy but it works. If somebody has a better idea, please let me know :smile:

What formula are you using to find the one to link?
FWIW if the automation is running on a batch of Campaigns, I can’t think that there can be a way to choose a particular one for the Order to be linked to, since each Campaign in the batch is unaware of the other items in the batch, so there is no way for any Campaign to know if it has the latest date.

I’ve already deleted the formula, but I’ve searched for orders

  • with no campaign activity
  • same contact
  • and date that matches the criteria (only orders of last 7 days can be linked)

If a contact opened 5 campaigns and those campaigns all get updated at the same time (because a user linked a product to those campaign) then the error occurred.

Yes that wasn’t possible when I start the automation in the campaign database.

But it is possible if I do it in the order database.

Because in a order I can filter and sort the campaigns on last campaign date.

[Campagne activiteits]
  .Filter(
    Find([Product ID], [Step 1 Order].[Product ID]) > 0 and
      [Datum laatste activiteit] >= [Step 1 Order].Datum - Days(7) and
      [Datum laatste activiteit] <= [Step 1 Order].Datum and
      [Step 1 Order].Contact = Contact
  )
  .Sort([Datum laatste activiteit])
  .Last()

So this workaround actually works pretty well :smile: I did a stress test with tons of campaigns + orders and the correct ones are linked now.

I assumed that this wasn’t possible since you wrote this:

and I thought that meant it needed to be triggered in the Campaign db.

Anyway…

Sounds good :blush:

Yes it needs to get triggered in the campaign database. But because of the extra relation with order (‘link all possible orders’) I can still manage it via order database (‘when possible campaigns are linked, then search for the best campaign to link to’) :smile:

However, it seems there is another problem.

If the campaign has product ID [1] [2] and the order has [2] [3] the orders are not linked correctly.

I was hoping that it still finds a match because [2] is present in both strings, but it seems that’s not the case?

Indeed. Comparing two collections to see what entities they have in common (or comparing two strings to see of they have any degree of ‘overlap’) is not possible as far as I know.

Still waiting on union and intersection functions :confused:

Noooooo :sweat_smile: that’s real f*cked up :exploding_head:

Is this a complex change?