Last modified: Oct 2, 2024

Prefilling data using configuration

How to configure prefill for an app using configuration files.

Using configuration only, Altinn apps support prefill with data from the Central Coordinating Register (Enhetsregisteret), the National Population Register (Folkeregisteret) and user profile in Altinn.

By following the description below, you will during instantiation of a form prefill the data model with the defined values obtained from Altinns data base.

Setup of prefill in the application repository

Create a new json file in the app repo under App/models. The name of the file should contain the name of the data model and have the postfix “.prefill.json”. If the data model is called appModel you should now be able to find these three files in the map: appModel.metadata.json, appModel.schema.json, appModel.prefill.json

Paste the code below into the file.

{
    "$schema": "https://altinncdn.no/schemas/json/prefill/prefill.schema.v1.json",
    "allowOverwrite": true,
    "ER": {
    },
    "DSF": {
    },
    "UserProfile": {
    }
}

Configuration of prefill.json

Within the category you want to fetch data from (ER, DSF or UserProfile) in the prefill.json file, add a new line with a key/value pair:

"<key>": "<value>"
  • The key is the field the data is fetched from-
  • The value is the field to populate in the data model.

A full overview of the available fields can be found here.

Example: Field from the Central Coordinating Register (ER)

The example below will populate the field Datamodell.Organisasjon.Organisasjonsnummer with the organization number retrieved from the Central Coordinating register.

"ER": {
    "OrgNumber":"Datamodell.Organisasjon.Organisasjonsnummer"
}

Example: Field from the National Population Register (DSF)

The example below will populate the field Datamodell.Person.Nummer with the phone number retrieved from the National Population Register.

"DSF": {
   "TelephoneNumber":"Datamodell.Person.Nummer"
}

Example: Field from the user profile in Altinn

The example below will populate the field Datamodell.Bruker.Epost with the email retrieved from the users profile in Altinn.

"UserProfile": {
    "Email":"Datamodell.Bruker.Epost"
}