How can I duplicate a data block to another "branch" of collections for editing?

Hello, dear NocoBase experts!

I have a data structure (collections) with “many-to-one” relationships that looks something like this:

  1. Orders
    1.1 Stages
    1.1.1 Stage Options

1.2 Contractor Bids
1.2.1 Contractor Stages
1.2.1.1 Contractor Stage Options

That is, there are many-to-one relationships between collections. For example, collections 1.1 Stages and 1.2 Contractor Bids are related to collection 1. Orders.

The logic of actions should be as follows: When adding a new Contractor Bid, it is necessary that the form for adding a new bid automatically adds “rows” of data to the existing subforms for subsequent editing in exactly the same quantity as the “similar” rows (at least in terms of their number) in the “branch” Orders - Stages - Stage Options.

That is, you need to “duplicate” the data block, but not within the same collection, but in another collection with a similar number of similar collections.

Here is something similar to the Form Data Templates settings (which can be selected in the current record for copying, but copying will create a data block in the current collection, and I need it to be in another collection).

I made a very rough video, and I hope it clearly shows the “data transfer” from the Orders data block to the Contractor Bids data block. An important point is that it must be possible to edit the transferred data in the form.
duplicate-order-to-bid-1 (2)

Perhaps it is possible to do this through a workflow with manual data entry… but I don’t know how to make sure that the Contractor Bids form is pre-filled with exactly the same number of lines in the subforms as there are in the Order block subforms.
I don’t know what method to use… Maybe a loop, or something else in the workflow, or maybe there is some other way. I know that my case may be difficult to understand, so I am ready to answer any questions and provide additional explanations.
I would appreciate any advice!

When you add data in the first step, use a workflow to copy the data into the data table of the next step.

1 Like

@hongboji, thank you for your quick response!

But I don’t quite understand how to do this… I’m not very familiar with NocoBase yet, I’m just learning new features as I build. What do you mean by “first step” and “next step”? That is, when I click the Add button and the input form appears? And how do I add a nested subform (with the same number of records) when the add form opens?

You mentioned that I need to add a subtable using workflow… But I need a subform, because it will contain another subform. In other words, I need the “relationship structure” in the subforms to be filled in.

I made a video file on the test platform, please take a look, I recreated the layout there.
duplicate-order-to-bid-2 (1)

That is, to explain once again, when you click on the Add button (Contractor’s Bid), the data should already be filled in the open form (according to the configured conditions), similar to those added to the Order itself (2 Stages and 4 Options). And ready for further editing and/or saving.

If it’s not too much trouble, could you help me figure this out and demonstrate on a test example how this can be achieved, if you have some free time?
https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/on02hifb4i3/popups/nvz7c9isigv/filterbytk/346796233850880/tab/d6ewm5ycpgl
I think this “multi-level” functionality will be useful to other users in similar situations, as it allows multiple actions to be performed at once, which would otherwise have to be performed individually by the end user. I would be grateful for your help!

When you add an order, the workflow is triggered, and contractor data is generated according to your logic. The screenshot for adding a contractor is changed to editing existing data.

Thank you for your reply, but I still don’t understand how it should work… :worried: I probably don’t have enough experience. I’ll try to come up with something…

@hongboji I tried to configure this functionality on the Modern page (version 2), and I managed to display the same amount of data as in the “parent data branch.” That is, for example, if there is Order 1 and it contains Stage 1.1 and Stage 1.2, then when you click on the Add Contractor Bid button, a subform with two potential entries for Contractor Stages is automatically created and displayed in the add form (i.e., there are also two of them, just like the Stages in the Order).

But I can’t set up a rule so that in the Contractor Stages subform, the Order Stage field (a drop-down list of the associative field type) displays Stage 1.1 first and then Stage 1.2 in the next subform entry (below).

In this field, only the first value, Stage 1.1, is displayed in both records. I assume that the script simply “takes” the earliest record, or the record with the smallest ID, and inserts it into the field. Is it possible to place all records somehow, is there a placement rule? Maybe some sorting option…?

Other similar platforms allow you to place a “subset” in a special form block, where you can specify the placement parameter by sorting (for example, by descending ID, or by creation time, or something else). And there, as I understand it, there is some kind of loop for “iterating” through the records so that they are all placed one after another in a similar subform.

Is it possible to come up with something?

Well, further on (if the above can be implemented), I think it will be possible to implement a deeper structure - the Stage Options subform (which is located in the Stages subform). But for this, you need to specify in the Stage fields so that the Options can then be “linked” to the values.

Below is a video file demonstrating the settings and the result.
duplicate-order-to-bid-3

You can reproduce the actions on the page:
https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/gxpzwd86ai1/view/30a0353f123/tab/bf607d3e087/filterbytk/346796233850880