Field Rules with reference data

I use a reference (with max = 1) in a child object, and I want to create a field rule which refers to the value of this referenceData. This inspector shows that this value is available:

"referenceData": {
    "cms-property-object": {
        "iv": {
            "en": "int-max-number-of-listpoints"
        }
    }

I try to do this:
referenceData[‘cms-property-object’].iv.en.startsWith(‘int’)

Question 1) Any idea why this doesn’t work?
Question 2) The field has “en” despite it is not localized. Is this a bug?

Hi,

let me answer your questions:

  1. The referenced data is not part of the form directly. The items are queried by the reference editor on demand and therefore not available for field rules.

  2. If you give me a link I can have a look, why it is that strange.

@1) OK - Thx!
@ 2) Squidex Headless CMS
line 54 - has “en”, but parent data is not a localized string

Oh, thats the referenced data. This is only used for the content list, because we don’t want to make extra queries there. But because you can show the content list in multiple languages, the reference data has several layers. I actually have to check the code to remember how it works exactly, but in short: It is transformed and optimized for the UI and not the actual data.

Would it be a feasible feature request to allow field rules in this case?

I don’t think so. The field rules are working on data that can actually be changed. If you want to support references it would become very complicated.

For example:

  1. Field references are loaded on demand. Some users have such large schemas that the field editors are loaded lazily. In this case the information would not be available immediately.
  2. Even if we would not have the problem above, the form needs to be extended with these information, making it also very complex.

So there are some edge cases, where this feature would not be possible at all. I think there are other solutions. You could make a hidden field and denormalize your content with the information from the reference or something like that.