Setting the default value for a Many-to-One field (dynamic value) does not work

* Describe the bug

The default value for a Many-to-One selection field cannot be set if the value is configured using a dynamic expression (based on the value of another field in the current form).

It is important to note that this functionality is available in the settings, but for some reason it does not work, even though everything is configured logically and correctly.

* Environment

  • NocoBase version: 2.0.0-beta.15
  • Classic Page (v1)
  • Database type and version: PostgreSQL
  • OS: Windows
  • Deployment Methods: Docker

* How To Reproduce

If you connect the same collection (Currencies) with a many-to-one relationship to two other collections, and also connect these same collections to each other with a many-to-one relationship. Then try to display the default value in the Currencies field, which is based on the selected value of the related collection, the result will not be displayed.

Below is a short video file showing how to reproduce the problem.
set-default-value-dynamic-issue-1

The problem can be reproduced on the test version of NocoBase (click Add New).
https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/on02hifb4i3/popups/49sblmzszn2/filterbytk/338414241251328/tab/du7brynzz1c/popups/iuntjlhjg6f/filterbytk/338414750859264/sourceid/338414241251328

For fields with deep relationships, you need to load the reference and then try using linkage rules to hide the retained values.

1 Like

@hongboji Thank you for your reply, this is valuable information. I didn’t know that you need to output an “intermediate value” for complex relationships!

It’s quite an interesting solution, although not the “direct functionality” I had assumed in the settings, but it solves the problem. I think we can close the question.

Still, I initially tried to configure it according to the principles of logic, that is, as suggested in the “configuration path,” especially since I can select all the necessary components of the query “formula,” at least the functionality allows me to do so. It’s unfortunate that it doesn’t work as I would like it to.

Therefore, I would be glad if in the future (when you have the time and opportunity) you could make the functionality “direct,” without using “intermediate” values in the frontend to create queries in complex relationships.

But anyway, NocoBase is a very cool platform, the best I’ve seen so far!

@hongboji Please tell me, how can I hide these fields in the form interface?

These are association fields from related collections; they are not input fields in the current record, but only display values. I couldn’t find any conditional rule settings for these fields…

It is not possible to select settings in the association field itself, and the association field is not displayed in the Field Linkage Rules .


How can I hide them based on a condition (or just hide them without a condition)?

@hongboji I have another problem - it’s related to the Modern page (version 2) - can’t set a default value for the association field. I just can’t select an “object” to set the value. I need to select a field inside the “object”

In the example shown in the screenshot above, I want the Contact Role field (in the current record addition form) to be filled with the value recorded in the same field in the Users collection, depending on the selected User. But if I set the Role UID parameter, the value does not appear… (and if I specify the Role Name parameter, a rendering error occurs).

Or could it be because the Contact Role field is a many-to-many relationship field? (But still, I just can’t insert an “object” into a dynamic field.)

@hongboji, I know I’m bothering you a lot, but I still want NocoBase to be the most ideal tool for building complex web infrastructure.

I have two problems again (it seems like I’m setting everything up logically, but an error appears).

  1. Classic page (version 1). When adding a new entry in the add form window, I configured a subform in which I want to get the default value from a similar field (Rich Editor) in the Rich Text Editor field through the association field. But when I try to configure the default value, the value itself is not transferred to this field. And when I try to configure the default value again, a rendering error occurs…

set-default-value-dynamic-issue-rich_editor-v1-1

Error log:

TypeError: Cannot read properties of undefined (reading 'length')
    at https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:14:2556
    at Array.reduce (<anonymous>)
    at push.76095.c.reduce (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:1:5395)
    at I.value (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:14:2500)
    at https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:5:10969
    at I.D (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:6:2511)
    at I.value (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/npm.quill.73ac4f8f.async.js:5:10871)
    at push.71167.n.setEditorContents (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/1167.f1f49999.async.js:1:5248)
    at push.71167.n.componentDidMount (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/1167.f1f49999.async.js:1:3064)
    at Sc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:32117)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31898)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at yc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31796)
    at Jc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:31422)
    at rf (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:41435)
    at Us (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:40794)
    at Tc (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:37331)
    at ti (https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:54:3273)
    at https://cdn.nocobase.com/2.0.0-alpha.68.20260131153239/umi.df315ad7.js:56:34712

At the same time, a completely identical setting for a String field does not cause an error and works without any problems. The problem only occurs in the Rich Text Editor field. You can repeat this on the page (but the error may not appear unless you try to reconfigure the default value display).
https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/on02hifb4i3/popups/49sblmzszn2/filterbytk/338414241251328/tab/hheptvroy7v

  1. Modern page (version 2). Here, it is not possible to display any default values at all; they are simply not transferred… Although when configuring rendering errors (as in the case above), they do not appear. Perhaps this is due to the fact that version 2 of Nocobase is still in beta?

set-default-value-dynamic-issue-rich_editor-v2-1

The problem can be reproduced on the page (Add New button). https://a_8hwne7u84ho.v13.demo.nocobase.com/admin/gxpzwd86ai1/view/30a0353f123/tab/bf607d3e087/filterbytk/338414241251328

Sorry, it can’t be hidden; it’s my problem. I suggest using the “Data Selector” component.

1 Like

Oh, thank you, that’s a solution! I still have some questions, could you answer them when you have time? This is especially true for the Modern Page (version 2) - it’s very unfortunate that it’s not possible to configure the functionality in the same way as in version 1 (Classic)…