# \[DONE\] Duplicate many-to-many relations when an entity is duplicated

**URL:** <https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500>\
**Category:** Ideas & Features\
**Created:** [November 8, 2022, 10:00am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500 "2022-11-08T10:00:27Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![HSinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/hsinger/32/4059_2.png) [@HSinger](https://community.fibery.io/u/HSinger)\
**Post date:** [November 8, 2022, 10:00am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/1 "2022-11-08T10:00:27Z")

</div>

Is there a feature request for a duplicate function that also duplicates inner collections, references and files? If not… please can you add one for me? It would be really useful. Thanks

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [November 8, 2022, 1:51pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/2 "2022-11-08T13:51:08Z")

</div>

How do you imagine it would work if there is a multi-level hierarchy of databases?  
e.g.  
A → B  
B → C  
B → D

Does duplicating an A create duplicates of all Bs linked to it, and does this result in duplicating of all Cs and Ds linked to these Bs?

> [@HSinger](#):
>
> also duplicates … references

What do you mean by duplicating references?

> [@HSinger](#):
>
> also duplicates … files

I’m not sure that this is sensible. It would grow the storage space required unnecessarily.  
Instead, might it be better if Fibery supported a basic file storage system so that a file could be linked to from multiple places…?

---

<div class="post-metadata">

**Author:** ![HSinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/hsinger/32/4059_2.png) [@HSinger](https://community.fibery.io/u/HSinger)\
**Post date:** [November 8, 2022, 2:23pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/3 "2022-11-08T14:23:03Z")

</div>

For us, most relationships are many-many.

A duplicate of A would not create duplicates of entities in B, rather it would just inherit the relationships to the existing entities in B.

I fully understand this is a complex problem and there may not be a one-size-fits-all solution.

What do I mean by ‘References’? I don’t know. I was stealing from Michael. I thought he might know what he was talking about. Forgive me if I’m mistaken! 😜

> [@CHANGELOG: April 14 / Duplicate entity, Audit Log for all users, Convert entity improvements](https://community.fibery.io/t/changelog-april-14-duplicate-entity-audit-log-for-all-users-convert-entity-improvements/1557/1):
>
> Collections and References. For example,

As for files, you are quite right: It would be much better to have a file storage system whereby files can be linked to multiple places 👍

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [November 8, 2022, 2:28pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/4 "2022-11-08T14:28:58Z")

</div>

> [@HSinger](#):
>
> What do I mean by ‘References’? I don’t know. I was stealing from Michael.

Haha! In this context, I think he means to-one relation fields, which actually do get copied.  
But copying many-to-many relations (i.e. linking to existing items) doesn’t bring with it many headaches, so I guess this should be a feature request.

UPDATE: I’ve split these messages out into a new topic

The file store topic is probably a bigger can of worms though 😉

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [November 8, 2022, 7:49pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/5 "2022-11-08T19:49:49Z")

</div>

Intelligent handling of collections when duplicating entities is a very sensible and popular request. But different types of M2M relations need to be handled differently, according what they are actually modeling.

The problem is that each relation must be handled in accord with its “purpose” or abstract role, which Fibery doesn’t know anything about (although it could).

I.e., when duplicating an entity, some of its collections just need to be _copied_ (keep the existing entity references), while other collections need the entities cloned/duplicated and linked appropriately.

The difficult part is to define how each relation should be handled – _copy, clone, or ignore?_ – and this must be done recursively for every DB related to the “root” entity being duplicated.

I actually wrote a script to do this, but I never finished it because of how frustrating the debugging experience was, plus some vexing limitations of the older version of Node in use – e.g. no support for `Promise.allSettled()` – which contributed to the debugging difficulty. If Fibery updates their Node version perhaps I will continue that project. 😀

* * *

_ **Different types of M2M relations, and how they should handled:** _

**(1) Multi-select / “tags” collection**  
One side of this relation is a DB of “tags” (or multi-select options), and the other side is any other DB where each entity has its own unique set of tags/options.

For relations of this type, the “main” entity’s references to Tags are simply replicated (not cloned).

**(2) Hierarchical “parent-child” tree structure**  
A self-relation implementing a strict tree structure; e.g. tasks with sub-tasks, pages with sub-pages, etc.

This case is also easy, if the intent is to duplicate/recreate an existing strict tree structure from a certain node on down. Depth-first cloning of the tree, replacing the parent & child references with their clones.

**(3) Graph**  
A self-relation implementing a graph structure.

More complicated than a tree, but still amenable to duplication of the _entire_ graph. Traverse the graph, cloning each entity as you go, then re-traverse, replacing the original entity references with their respective clones.

**(4) Other**  
Any M2M relation that _isn’t_ well-defined is not suited to automated cloning/duplication. But the above is not an exhaustive list – there are probably additional relation types/use-cases that would be amenable.

* * *

The real point here is that if we can **define a particular M2M relation’s purpose** (and have its limitations enforced by Fibery, e.g. a strict tree-structure), then it becomes a reasonable subject for automated duplication.

Fibery could offer some new relation types like “Tree”, “Tags”, “Graph”, etc. (which would just be restricted M2M types under the hood). We already have a version of “Tags” in the Multi-Select list, but its limitations are too restrictive for many uses – e.g. they are limited to a single DB.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [November 8, 2022, 7:56pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/6 "2022-11-08T19:56:45Z")

</div>

> [@Matt\_Blais](#):
>
> The real point here is that if we can **define a particular M2M relation’s purpose** (and have its limitations enforced by Fibery, e.g. a strict tree-structure), then it becomes a reasonable subject for automated duplication.
> 
> Fibery could offer some new relation types like “Tree”, “Tags”, “Graph”, etc.

Although this is a very intelligent approach, I fear that more ‘casual’ users will be put off by Fibery trying to teach them the necessary concepts around relation types 😕

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [November 8, 2022, 8:16pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/7 "2022-11-08T20:16:38Z")

</div>

LOL yeah I suppose it could become a problem when Fibery needs to explain WHY some entity can’t just be automatically cloned/duplicated, the way the user expects it “should” be… _“but it seems simple enough to me!”_

---

<div class="post-metadata">

**Author:** ![Eren\_Turgut](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/eren_turgut/32/4425_2.png) [@Eren\_Turgut](https://community.fibery.io/u/Eren_Turgut)\
**Post date:** [November 9, 2022, 9:35am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/8 "2022-11-09T09:35:14Z")

</div>

I don’t think Fibery should focus on casual users. Fibery should be as powerful as it could be, because people who are NOT casual users will set up workspaces for their own or other companies or create templates that are usable for casual users.

SAP is neither easy to setup, nor easy to learn/use. Most users don’t even remotely use all functionalities, they just learn whatever they have to to do their work.

---

<div class="post-metadata">

**Author:** ![Lod](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lod/32/8358_2.png) [@Lod](https://community.fibery.io/u/Lod)\
**Post date:** [February 20, 2024, 5:09pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/9 "2024-02-20T17:09:36Z")

</div>

Hi! Is there any update on this request?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 20, 2024, 7:07pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/10 "2024-02-20T19:07:36Z")

</div>

Nothing to report. It’s not planned in the near future.

---

<div class="post-metadata">

**Author:** ![gomocoop](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gomocoop/32/6349_2.png) [@gomocoop](https://community.fibery.io/u/gomocoop)\
**Post date:** [October 14, 2024, 6:21pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/11 "2024-10-14T18:21:02Z")

</div>

Hey! Found this topic and was wondering if it is the exact same need that I have…

I’ll try to explaind.

I’d like to be able to duplicate an entity and keep some of it’s fields the same… after lots of help from Fibery IA and ChatGPT, I manage to create a script for a button that does this. However, there is a One-Many relation field that I couldn’t work out.

At some point of my script I define the fields (all Single Select field) that should be the same

```auto
 await fibery.createEntity('Workshift', {
        "DATE OF WORKSHIFT": datePlus28.toISOString(),
        "WEEK": (originalWEEK),
        "DAY OF THE WEEK": (originalDAY OF THE WEEK),
        "WORKSHIFT TIME": (originalWORKSHIFT TIME),

```

PS: The date for the new entity I want it to be plus 28 days.

But if I write something like

`"PERSON IN CHARGE": (originalPERSON IN CHARGE)`

It doesn’t work the same way…

Any thoughts?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [October 14, 2024, 9:25pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/12 "2024-10-14T21:25:42Z")

</div>

What type of relation is `PERSON IN CHARGE`?  
And where is `(originalPERSON IN CHARGE)` coming from?

---

<div class="post-metadata">

**Author:** ![gomocoop](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gomocoop/32/6349_2.png) [@gomocoop](https://community.fibery.io/u/gomocoop)\
**Post date:** [October 15, 2024, 8:12am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/13 "2024-10-15T08:12:20Z")

</div>

`PERSON IN CHARGE` is a relation (one-many). It is a field inside the entity, connecting to a database called COOPERATIVES.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [October 15, 2024, 8:31am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/14 "2024-10-15T08:31:09Z")

</div>

You’ll need to use `addCollectionItem` (or `addCollectionItemBatch`)

---

<div class="post-metadata">

**Author:** ![gomocoop](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gomocoop/32/6349_2.png) [@gomocoop](https://community.fibery.io/u/gomocoop)\
**Post date:** [October 15, 2024, 8:33am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/15 "2024-10-15T08:33:57Z")

</div>

An in the script how would it be written?

```auto
await fibery.createEntity('Workshift', {
        "DATE OF WORKSHIFT": datePlus28.toISOString(),
        "WEEK": (originalWEEK),
        "DAY OF THE WEEK": (originalDAY OF THE WEEK),
        "WORKSHIFT TIME": (originalWORKSHIFT TIME),
        "COOPERATIVES: addCollectionItem

```

Like that? I’m a real newbie in programming and javascript…

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [October 15, 2024, 9:04am UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/16 "2024-10-15T09:04:00Z")

</div>

`addCollectionItem` has to be used as a function subsequent to the `createEntity` function

---

<div class="post-metadata">

**Author:** ![mdubakov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/mdubakov/32/10_2.png) [@mdubakov](https://community.fibery.io/u/mdubakov)\
**Post date:** [April 2, 2026, 2:11pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/17 "2026-04-02T14:11:10Z")

</div>

Implemented in latest release

> [@parrot April 2, 2026 / Show Fields from relation without Lookup, AI Integration Agent](https://community.fibery.io/t/april-2-2026-show-fields-from-relation-without-lookup-ai-integration-agent/10679):
>
> potted_plant Show Fields from relation without Lookup Now you can display Fields of related Entities on Views. Here are a couple typical use cases: On a Table View with Contacts, display columns for Contact → Company → State and Contact → Company → Revenue to understand how rude you can be nice you should be to each person. On an Entity View for Employees, show Employee → User → Vacations to save yourself a click. Unlike Lookups, these related Fields: are editable; respect acces…

---

<div class="post-metadata">

**Author:** ![mdubakov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/mdubakov/32/10_2.png) [@mdubakov](https://community.fibery.io/u/mdubakov)\
**Post date:** [April 16, 2026, 1:22pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/18 "2026-04-16T13:22:01Z")

</div>

collections are duplicating now as well

> [@April 16, 2026 / gorilla Automatically link entities with more operators, Text color in rich text, Filter and sort relation selectors in Forms, Share with all users with a particular email domain](https://community.fibery.io/t/april-16-2026-automatically-link-entities-with-more-operators-text-color-in-rich-text-filter-and-sort-relation-selectors-in-forms-share-with-all-users-with-a-particular-email-domain/10744):
>
> A bulky release today with some quality of life improvements and… zero AI features (not sure whether it is good or bad though smiling_face_with_tear). Automatically link entities with more operators Before, you could use only = when describing Automatic Link Rule for a Relation Field. We extended the list of allowed operators. Now you also have: For Relation Fields: to-one relation is in to-many relation For Text Fields: starts with, ends with, contains For Date Fields: date field is within …

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [April 16, 2026, 4:10pm UTC](https://community.fibery.io/t/done-duplicate-many-to-many-relations-when-an-entity-is-duplicated/3500/19 "2026-04-16T16:10:03Z")

</div>


