Intra-Space Deep Copy

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


  • 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)

I can certainly take a shot at writing a js automation, but after reviewing the scripts in automation guide, 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?

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?


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 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 :slightly_smiling_face:



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…

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 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.


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!

1 Like

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

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… :grinning:

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!


@IMTanuki Also see this post for a basic cloner script.


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… :grinning:


1 Like

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… :grinning: :grinning: :grinning:

1 Like

@IMTanuki do you have a feature request for this?
I came across Airtable’s Template feature today and want to share how it works with the Fibery team for consideration.

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 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.

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


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)

1 Like