# Intra-Space Deep Copy

**URL:** <https://community.fibery.io/t/intra-space-deep-copy/6079>\
**Category:** Get Help\
**Created:** [April 13, 2024, 4:40am UTC](https://community.fibery.io/t/intra-space-deep-copy/6079 "2024-04-13T04:40:23Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 13, 2024, 4:40am UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/1 "2024-04-13T04:40:23Z")

</div>

More and more, I’m running into situations where I need to deep copy an entity and its children / grandchildren (structure and content). Typically, this is a project in a space, where I want a second (third etc) instance of that project in the _same_ space.

The data hierarchy is:  
project 1:M sections  
section 1:M tasks  
task 1:M sub-tasks

…no M:M associations

**Workarounds**

- I’ve tried duplicating at the space level, but what I really need is to duplicate a project _within a space_.

- I’ve tried automation, but I’m not seeing any functions that iteratively copy entities(e.g. all tasks in a section)

**Javascript**  
I can certainly take a shot at writing a js automation, but after reviewing the [scripts in automation guide](https://the.fibery.io/@public/User_Guide/Guide/Scripts-in-Automations-54), I’m not sure I’ve got a complete understanding of the Fibery object model. Likewise, I did a search thru the templates for example js.

- is there an example of javascript that copies an entity?

**Roadmap**  
I understand that Fibery is unopinionated, but I really think that a deep copy function, even one with limitations, would be valuable to many users.

- is a deep copy function in the roadmap, even long-term?

Thx!

---

<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:** [April 14, 2024, 10:18pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/2 "2024-04-14T22:18:03Z")

</div>

Search this forum for “clone” for additional discussion.

* * *

A real, general purpose cloner/“deep copy” script for Fibery is very complex - I have written one that is over 550 lines long, and it still has limitations and tradeoffs.

Fibery automations have hard limits on CPU and runtime, which limits how much you can accomplish in a single automation. You can create workarounds by moving the logic to another platform like [n8n.io/Make.com/Zapier](http://n8n.io/Make.com/Zapier) to avoid the CPU limits, but this incurs additional platform cost and complexity, as well as potentially introducing race/consistency issues.

You will never have a single, self-contained Fibery automation that can clone an _arbitrarily complex_ set of related entities, which could number hundreds of entities.

Consider a “Workflows” system in Fibery that consists of the DBs: Workflow, Task, Action, and Parameter. A “template Workflow” – with all its related Tasks, Actions and Parameters – will need to be cloned to create a new instance of the Workflow.

Cloning a template Workflow implies cloning the entire related structure of Task, Action, and Parameter entities, and recreating all those relationships from the template Workflow between the corresponding cloned entities.

When you consider how to handle Rich Text Fields, attached Files, links to Users, auto-linked relations, other Fibery field types, plus discerning which relation fields need to be preserved instead of being cloned, it is a very complex task.

On top of that there is no debugging support for scripts – it is a very challenging scripting environment, as @mdubakov noted, not designed for such complex scripts.

But we love it so much, we just keep pushing the boundaries 🙂

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 15, 2024, 12:06am UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/3 "2024-04-15T00:06:22Z")

</div>

Matt,

Thx for the quick reply. I am fully aware that Fibery’s unopinionated design translates to complexity for sth like a generalized deep copy. But I don’t think that negates the need for this function.

But on the other hand, I don’t see how a fairly straightforward project tracker like mine (project 1:M section 1:M task) can be automatically created for each new project, other than exporting/importing an extire space, which I think undermines the space-project concept.

Correct me if I am wrong, but my choices now are:

- manually create each new project in a space, which means I lose any content that I might have accumulated in the original project.

- forego the idea of having multiple projects in a single space and share as template at the space level.

In the long term, I’d rather write 500 lines of code than manually create each new project, but I would need a more detailed overview of the Fibery objects and methods - does this exist for users?

Sometimes less is more…

---

<div class="post-metadata">

**Author:** ![Yuri\_BC](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yuri_bc/32/8803_2.png) [@Yuri\_BC](https://community.fibery.io/u/Yuri_BC)\
**Post date:** [April 15, 2024, 7:49am UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/4 "2024-04-15T07:49:12Z")

</div>

I think what you ask its not so complicated to accomplish in a script, see for example [Entity Migration Script: Hierarchical Data Transfer Between Databases](https://community.fibery.io/t/entity-migration-script-hierarchical-data-transfer-between-databases/5899) which is not your use case but somewhat related.

You may be lucky this time, last week I did some work in creating pattern template maps as I call it, which allows users to clone an entire project tree. The functionality goes both ways: either create a tree from a template map, or save an existing custom tree as template map, with one click.

In the coming week I will share example code. This is assuming the Project, Section and Task are the databases that are used each time, but the entities and how they relate is unknown thus needs to be determined dynamically by the script.

Related but maybe interesting also: I’m currently also working on a databasemapping system that allows a script to use a custom set of databases in a preconfigured relation cluster, based on the databases that a user selects. Say you have 50 databases and want a custom mix of a few of those in a custom tree, the script can do that, as long as fields used are of the same types and show a corresponding pattern in their names.

I think what you ask is a common need when branching or forking a project, and is worth to be a Fibery feature, but the question is if the value proposition of Fibery, the product killer feature, gives what you want priority over its developpment needs, as like described in Fibery 2.0 that focus on insight through relationships.

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 15, 2024, 2:54pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/5 "2024-04-15T14:54:05Z")

</div>

Yuri,

Thx so much! This is darn close to what I’m trying to achieve (although I think your scripts go far beyond my basic requirements).

My situation is relatively straightforward - I have n projects, each project has a 1:M relation to sections, and each section has a 1:M relation to tasks. Maybe in the future I’ll add subtasks. But everything always follows this 1:M hierarchy.

As soon as I finish my coffee, I’ll start going thru your code.

_This is a real breakthrough!_ I think having a deep copy function will open the door for many more use cases and more users…I’m looking forward to seeing the other examples you are working on.

Thx again!

---

<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 15, 2024, 2:57pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/6 "2024-04-15T14:57:17Z")

</div>

> [@IMTanuki](#):
>
> But on the other hand, I don’t see how a fairly straightforward project tracker like mine (project 1:M section 1:M task) can be automatically created for each new project, other than exporting/importing an extire space, which I think undermines the space-project concept.

If you have a fixed structure, it isn’t that hard to write a specific script that will clone the entities (with whichever relevant fields included) but as @Matt_Blais writes

> [@Matt\_Blais](#):
>
> A real, general purpose cloner/“deep copy” script for Fibery is very complex

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 15, 2024, 4:56pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/7 "2024-04-15T16:56:15Z")

</div>

Hey Chris,

Thx for jumping in to clarify. Yeah, I’m not trying to create a general purpose deep copy - as we’ve discussed in the past, given Fibery’s almost limitless configurability, that would definately be above my pay grade… 😀

But in my case, a very narrowly focused copy function that assumes 1:M relationship at each level seems doable, as long as I can figure out the object model, which I think (hope) is shown in Yuri’s example.

If I can get this addressed, I’ll be all set!

Thx!

---

<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:** [April 15, 2024, 7:17pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/8 "2024-04-15T19:17:18Z")

</div>

@IMTanuki Also see [this post](https://community.fibery.io/t/done-duplicate-a-record/386/7) for a basic cloner script.

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 15, 2024, 9:43pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/9 "2024-04-15T21:43:48Z")

</div>

@Matt_Blais

Thank you! This may take me a little bit to work thru all the code you and @Yuri_BC provided, but I’m confident I’ll end up with the solution I need.

This is great - this makes Fibery a complete solution for 99% of my use cases… 😀

Cheers

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [April 16, 2024, 5:26am UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/10 "2024-04-16T05:26:55Z")

</div>

Thx @Matt_Blais @Yuri_BC , @Chr1sG for all your insights and examples. I’m half way thru my code - my different db’s are sufficiently different that I need to write a special branch to read/write fields based on the db in my hierarchy, but I don’t think it should be a big deal. This is going to make a huge difference in usability for me… 😀 😀 😀

---

<div class="post-metadata">

**Author:** ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)\
**Post date:** [May 2, 2024, 8:52pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/12 "2024-05-02T20:52:07Z")

</div>

@IMTanuki do you have a feature request for this?  
I came across [Airtable’s Template](https://support.airtable.com/docs/using-record-templates-in-airtable) feature today and want to share how it works with the Fibery team for consideration.

---

<div class="post-metadata">

**Author:** ![IMTanuki](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/imtanuki/32/7751_2.png) [@IMTanuki](https://community.fibery.io/u/IMTanuki)\
**Post date:** [May 2, 2024, 10:47pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/13 "2024-05-02T22:47:24Z")

</div>

I think the consensus from the community has been that highly (or not so highly) customized spaces could break this kind of function. So the prototype I posted [Share Your Space](https://community.fibery.io/t/deep-copy-within-a-space/6143) is hardwired to the schema I used.

Who knows - maybe better minds than mine can figure out how to make this work for a broader set of use cases, so I just added a [feature request](https://community.fibery.io/t/deep-copy-intra-space/6144).

---

<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:** [May 3, 2024, 5:39pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/14 "2024-05-03T17:39:00Z")

</div>

If anyone needs a fully-featured entity “cloner”, I can help via consulting (DM me).

---

<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:** [May 3, 2024, 8:29pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/15 "2024-05-03T20:29:07Z")

</div>

I’ve actually just cobbled something together that I was going to share with the community next week.

(I didn’t do this to undermine your offering @Matt_Blais I just started it out of curosity and made reasonable progress)

---

<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:** [May 6, 2024, 2:09pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/16 "2024-05-06T14:09:38Z")

</div>

> [@Generic cloning of a hierarchy](https://community.fibery.io/t/generic-cloning-of-a-hierarchy/6152):
>
> Following [a bit of discussion](https://community.fibery.io/t/intra-space-deep-copy/6079) here in the community about duplicating hierarchies of entities, I put together [a space](https://shared.fibery.io/t/f259b072-d358-4a15-b556-bbafe60b5c37-deep-clone) which can be used to clone a top-level entity and all its children, grandchildren etc. At the moment, any items linked via a one-to-many relationship will be cloned (as will any items linked to them via 1:m, and so on…) m:m, m:1 and 1:1 relations are ignored, with the exception of m:? relations to users (e.g. Assignees, Owner, etc.). Once you have installed the space, go to t…

---

<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:23pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/17 "2026-04-16T13:23:08Z")

</div>

Duplicate action nows deep copy entities

> [@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:07pm UTC](https://community.fibery.io/t/intra-space-deep-copy/6079/18 "2026-04-16T16:07:02Z")

</div>


