Altinn / app-localtest

Solution for testing apps locally on your own machine
8 stars 14 forks source link

Fields in nested repeating groups cannot be used in or from in resource-files #39

Closed violaguttorm closed 1 year ago

violaguttorm commented 1 year ago

Description of the bug

We have a nested repeating Group, and we would like to use a value from the inner Group in a text appearing in the same inner Group. However, this doesn't work and just displays the {0} directly on the page:

    {
      "id": "mellomliggende.norskutenlandsk.title",
      "value": "__{0}__",
      "variables": [
        {
          "key": "skjemainnhold.skjemadata.reellRettighetshaver[{0}].posisjonEierMellomliggendeVirksomhet[{1}].virksomhet.navn",
          "dataSource": "dataModel.Brønnøysundregistrene_ReelleRettighetshavere_M"
        }
      ]
    },

It does work if you set it up like this (note the hardcoded array-keys):

    {
      "id": "mellomliggende.norskutenlandsk.title",
      "value": "__{0}__",
      "variables": [
        {
          "key": "skjemainnhold.skjemadata.reellRettighetshaver[0].posisjonEierMellomliggendeVirksomhet[0].virksomhet.navn",
          "dataSource": "dataModel.Brønnøysundregistrene_ReelleRettighetshavere_M"
        }
      ]
    },

But as soon as you try to use any variable in the key-part of the variable, it just displays {0}. This does NOT work, for instance (note only one variable in the key):

    {
      "id": "mellomliggende.norskutenlandsk.title",
      "value": "__{0}__",
      "variables": [
        {
          "key": "skjemainnhold.skjemadata.reellRettighetshaver[{0}].posisjonEierMellomliggendeVirksomhet[0].virksomhet.navn",
          "dataSource": "dataModel.Brønnøysundregistrene_ReelleRettighetshavere_M"
        }
      ]
    },

And for fun, trying to use a nested list-element outside of a nested list does not work (as expected), BUT it does not display {0} on the page, it displays nothing (which is as expected).

This bug was discovered in https://altinn.studio/repos/brg/rrh-innrapportering, though the code that triggers it is not merged yet.

Steps To Reproduce

  1. Create a nested Group
  2. Try to use a variable from the dataModel within the inner Group in a text within the inner Group.

Additional Information

No response

violaguttorm commented 1 year ago

Reported in wrong place.

New link: https://github.com/Altinn/app-frontend-react/issues/1191