Relations removed by automations

Hello!

I’ve built an automation that’s supposed to relate an item from app A to an item from app B. The trigger occurs upon creation (i.e., when an item is created in app A, it should relate it to an item in app B). The issue I’m facing is when two items are created at the same time, or within a few seconds of eachother: the automations are running at nearly the same time, causing the relation to be removed shortly after it is made.

image

It’s important to notice that there isn’t any actions to remove relations on my automation…

2 Likes

I’m curious - how is it linking to the related item? Is it a search operation or something else? That might help the devs to identify the issue better. Maybe you could also add a screenshot or description of your automation.

2 Likes

There’s a relation field on app A that relates to multiple records of app “OC | Itens”.

So my automation gets records of a view and filter the records following established parameters. If it finds any record that meets these parameters, it should take these multiple items on the relation field on app A and add them to the relation field on app B.

A similar case is happening on another organization with an automation I built that follows the same logic.

1 Like

Hi @agnes.farias,

thank you so much for the report! We believe we already have a good idea of what’s causing your issue. To provide a solution, we need to know whether you’re using one or two automations for the process.

If you’re using two automations, the solution would be to merge them into one. If you’re using only one automation, we would need a screenshot of the complete automation to assist you further. Feel free to send me the screenshot as a private message here in the community if it contains sensitive data.

Here’s some background to help you understand the issue: The Tape API (which the Tape automations use) currently only supports a “set” operation per field. Even though “Add records” is selected in the editor, it always sets both the existing and new records in one set operation. Since each customer is currently allocated two parallel runs to process automations, two flows that are triggered at the exactly same time and write to the same field in the same record have a high chance to overwrite each other. In very rare cases, this can also happen with a single automation, but this requires the automation to be triggered twice at the same time, making it run in parallel twice in the two slots, which is very difficult to reproduce.

Best regards,
Leo

2 Likes

Hi @Leo , thank you for your time and for the background.

I’m only using one automation. The system I built on Tape is responsible to manage purchase orders from a school, and this app should receive orders from different departments and merge them into one. My automation is set on a app not available for the school (app A) and it runs a loop through a list of classifications (for instance: food, cleaning supplies, etc.) and gather all purchase items related to this classification and create an item on app B for it OR relates the purchase items if an item for this classification already exists there.





2 Likes

Hi @agnes.farias,

thanks for sharing your advanced use-case. Your screenshots provide a good overview, only one thing is missing: How do you trigger your flow? And is it possible that it triggers consecutively / in parallel within a short amount of time?

The observed behaviour, where the relation is set and then removed, indicates a race condition in most scenarios that I have experienced. One workflow execution “reads” the record, alters it, and meanwhile another execution had also already read the previous, unaltered version of the record and attempt to make a change - overwriting the first one.

I see two potential ways to solve this:

  1. Understand why two flows execute within a short amount of time and eliminate the race condition, e.g. by changing your trigger or making it more explicit.

  2. Make your record update conditional, such that the record action only executes if a proper relatable record was found. You could achieve this by using a conditional to wrap your record update, and let your flow end “early” if no relation will be set. This would prevent an empty update that might clear the previous alteration of another run / workflow.

I hope that was comprehensive. Maybe the community also has other ideas on how to improve your flows. Feel free to share your trigger as well, and maybe share your run logs for the scenario mentioned.

Cheers
Tim

1 Like