Repeating groups

Setup for repeating groups.

Groups in the data model contain one or more fields. Groups are defined as repeating if they have maxOccurs > 1 in the xsd. A group that is repeating in the data model must also be set up as repeating in the form, if not, data saving will fail.

Example

Form with some single-fields and a repeating group that:

  • contains three fields
  • can be repeated up to three times
Form with repeating group

Form with repeating group

Setup in FormLayout.json from the example above:

 1{
 2  "data": {
 3    "layout": [
 4      {
 5        "id": "gruppe-1",
 6        "type": "Group",
 7        "children": [
 8          "ac555386-ac2b-47a0-bb1b-842f8612eddb",
 9          "5c079cd4-c80c-44ea-b8b8-18e323267a37"
10        ],
11        "maxCount": 3,
12        "dataModelBindings": {
13          "group": "spesifisering-grp-5836"
14        },
15        "textResourceBindings": {
16          "header": "person"
17        }
18      },
19      {
20        "id": "ac555386-ac2b-47a0-bb1b-842f8612eddb",
21        "type": "Checkboxes",
22        "componentType": 5,
23        "textResourceBindings": {
24          "title": "Avkrysningsboks"
25        },
26        "dataModelBindings": {
27          "simpleBinding": "klage-grp-5805.spesifisering-grp-5836.KlageSpesifisering-datadef-25457.value"
28        },
29        "options": [
30          {
31            "label": "25795.OppgavegiverNavnPreutfyltdatadef25795.Label",
32            "value": "Verdi1"
33          },
34          {
35            "label": "25796.OppgavegiverAdressePreutfyltdatadef25796.Label",
36            "value": "Verdi2"
37          }
38        ],
39        "required": true
40      },
41      {
42        "id": "5c079cd4-c80c-44ea-b8b8-18e323267a37",
43        "type": "AddressComponent",
44        "componentType": 11,
45        "textResourceBindings": {
46          "title": "Adresse" 
47        },
48        "dataModelBindings": {
49          "address": "klage-grp-5805.spesifisering-grp-5836.KlageSpesifiseringg-datadef-12345.value"
50        },
51        "simplified": true,
52        "readOnly": false,
53        "required": true
54      }
55    ]
56  }
57}

File attachment in repeating groups

This is new functionality. Setup must be done manually for now.

To set up file uploading components in repeating groups, some additional setup is required.

When uploading file attachments it may be difficult to distinguish which file attachments belongs to which rows in the repeating group, and thus which submitted information belongs to each attachment. Therefore, you must set up connections to the data model when file uploading are used in repeating groups, so that Altinn can fill out the unique identificator that belongs to each file attachment and send this together with the rest of the data in the instance.

The ability to place a reference to the file attachment in the data model can also be used outside of repeating groups if you want a reference to a file attachment together with the form data on the receivers end.

Example on file attachment in repeating group with attached data model

Example on file attachment in repeating group with attached data model

The following is an example of a data model expecting a reference to an uploaded file attachment.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xsd:element name="FamilieMedlemmer" type="Skjema" />
  <xsd:complexType name="Skjema">
    <xsd:sequence>
      <xsd:element name="FamilyMember" type="FamilyMember" maxOccurs="99" />
    </xsd:sequence>
    <xsd:anyAttribute />
  </xsd:complexType>
  <xsd:complexType name="FamilyMember">
    <xsd:sequence>
      <xsd:element name="FirstName" type="xsd:string" />
      <xsd:element name="Picture" type="xsd:string" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

This is connected to the file upload component in the group:

{
  "id": "picture",
  "type": "FileUpload",
  "textResourceBindings": {
    "title": "Picture"
  },
  "dataModelBindings": {
    "simpleBinding": "FamilyMember.Picture"
  },
  "maxFileSizeInMB": 25,
  "maxNumberOfAttachments": 1,
  "minNumberOfAttachments": 1,
  "displayMode": "simple",
  "required": true
}

In cases where it is allowed to upload multiple files to the same file attachment component, use a data model attachment of the type list:

  <xsd:complexType name="FamilyMember">
    <xsd:sequence>
      <xsd:element name="FirstName" type="xsd:string" />
      <xsd:element name="Pictures" type="xsd:string" maxOccurs="5" />
    </xsd:sequence>
  </xsd:complexType>
{
  [...]
  "dataModelBindings": {
    "list": "FamilyMember.Pictures"
  }
}

The receiving end will then receive a list of multiple unique ID’s, one for each attachment. The same unique ID will also be displayed in the PDF receipt - but it is recommended to hide this, as attachments are shown seperately on the receipt page and the unique ID can become confusing to the users.