Module 4

Add code lists manually, progmatic and dynamically

In this module you’re expanding the application you made in the previous modules to support even more of the requirements of the municipality of Sogndal.

Topics covered in this module:

  • Code lists/Options
  • Dynamic


In many applications there is a need to provide the user with a set of response options for a data field. The answer options are referred to as code lists or options.

In Altinn Studio this is supported in the form of radio buttons, checkboxes and dropdown lists.

There are three ways to set up code lists in Altinn today

  1. Directly on the component through Altinn Studio or manually in FormLayout.json*

  2. In a static json-file referred to in the component

  3. Programmatic in the application logic

    * only available on radio buttons and check boxes

In this task, you will get to try out all three ways to set up a code list.

The municipality of Sogndal wishes to collect information on the newcomers working situation. Some of the data they wish to collect is which sector and industry the newcomer works in, and how many years the newcomer has been active in the workforce.

In Altinn Studio

  1. Create a new form page to collect data about working conditions

  2. Set up a radio button component for Sector. Create the answer options Offentlig and private manually.

  3. Set up a check box component for Industry. Choose Kodeliste as method for adding checkboxes and add Kodeliste ID industry

    The rest of the setup for this component is done locally

  4. Set up a dropdown list for Years in work force Add Kodeliste ID years-in-work-force

    The rest of the setup for this component is done locally

  5. Commit and Push your changes to master, and Pull the changes to your local development environment.

In Local Development environment

  1. The municipality of Sogndal has created a code list for industries. Download the file and place it correctly in the repository.

  2. Set up the values in the code list for Years in work force directly in a new C# class.

    Answer options:

    Label Data value
    0 - 5 years 0-5
    5 - 10 years 5-10
    10 - 20 years 10-20
    20+ years 20+
  3. Verify that all code lists works as expected.

Useful documentation

Knowledge check

  • What is the difference between static and dynamic options?
  • What will the area of use be for secured dynamic options?

In some cases the values displayed in a code list may be attached to a different field in the form.

The municipality of Sogndal wishes that the list of industries to choose from is personalised to what sector you work in.

Read through the requirements from the municipality to see if you can help them.

Requirements from the municipality

We want the user to be presented with a different set of options for the industry choice based on which sector they are in.

Useful documentation

Knowledge check

  • If a list of options is set up with mapping towards the data model - what happens when the field in question changes value?
  • What happens with the chosen value on a field connected to an option-list that is retrieved over again from the server side?

Requirements from the municipality

If the user chooses IKT (data/it) under industry, a text with a link to our overview of vacant positions should appear.

  • Below the industry choice, the following text should appear

    Vi ser at du besitter kompetanse vi trenger i kommunen.
    Se en oversikt over våre ledige stillinger her.
  • Line 2 in the text should be a link that directs to:

The text and link should only be visible if the user has chosen IKT (data/it). In all other cases this will be hidden.

Useful documentation

Knowledge check

  • If you add a new function to RuleHandlerHelper - where will these functions run?
    • Would dynamic work without this defined?
  • What is the correlation between functions defined in RuleHandlerObject and the file RuleConfiguration.json?


In this module you have set up a dropdown list, radio buttons and checkboxes and added values for these components manually, programmatically and dynamically.

The service should run on your local computer with local test and you should be able to validate that the components present expected data values.

Remember to push your local changes, so that they are available in Altinn Studio when you’re happy with them


If you did not manage to complete all the steps, we have an example of a solution that you can use as inspiration.

Screenshot of collection of work information for private sector Screenshot of collection of work information for public sector