Filter N entity in automation formula

I have an automation formula that adds the first empty (free) entity.
Kings.Filter(IsEmpty(Setups) = true)
.Sort([Public Id])

How can I get 5 entities at once?

I am not aware of an easy way of doing it, but you could achieve it by adding 1 entity at a time, five times.

However, for each action (except the first) you would need to include in the filter condition that it is not already linked, which may or may not be easy (possible?) depending on the relation type (one-to-many :+1: many-to-many :-1: )

Thanks for the idea! but it probably won’t work that way because the trigger is set to add a new line. Some kind of automatic filling of fields. You can’t call it 5 times in a row.

I guess I’ll have to try to find a solution through JS

Maybe I misunderstood, but I meant that you could use 5 actions in one automation, with the same formula each time, that checks for which entity should be linked.

Here’s an analogous example where I am linking a Project to the top 3 Deliverables (ordered by Creation date) which are not Done and are not already linked to a Project:

This is the formula:

Deliverables.Filter(Done = false and IsEmpty(Project))
  .Sort([Creation Date])

And here’s what happens when it runs:

Is this close to what you need?

Yes, it did! Thank you!
I didn’t realize it at first and did it wrong with UPDATE.
I should have done it with LINK. ))))