How to store data in ein array using Forms steps

Hello,

I used Forms to create profile data form after first login. The only part I’m struggling is how I cant store with the Flow Update profile into an array.

In the form I have three steps every step allows to store information for one child with name, gender and birthdate.

I want to store it in the user_metadata like this:

 "user_metadata": {
    "children": [
      {
        "first_name": "Luca",
        "last_name": "Mustermann",
        "gender": "m",
        "birthdate": "2018-05-12"
      },
      {
        "first_name": "Sophie",
        "last_name": "Mustermann",
        "gender": "f",
        "birthdate": "2019-10-07"
      }
    ],`...``

I tried different ways and also the merge helper function but at the end I always have only the last entry in the profile.

{
  "children": [
    {},
    {},
    {
      "gender": "Unknown",
      "birthdate": "2025-05-30",
      "last_name": "Ranseier",
      "first_name": "Karl"
    }
  ],

Last try was this mapping which results in data above, so what I see is that the form data could be lost.

{
  "user_metadata": {
    "children": [
      {
        "gender": "{{fields.child1_gender}}",
        "birthdate": "{{fields.child1_birthdate}}",
        "last_name": "{{fields.child1_last_name}}",
        "first_name": "{{fields.child1_first_name}}"
      },
      {
        "gender": "{{fields.child2_gender}}",
        "birthdate": "{{fields.child2_birthdate}}",
        "last_name": "{{fields.child2_last_name}}",
        "first_name": "{{fields.child2_first_name}}"
      },
      {
        "gender": "{{fields.child3_gender}}",
        "birthdate": "{{fields.child3_birthdate}}",
        "last_name": "{{fields.child3_last_name}}",
        "first_name": "{{fields.child3_first_name}}"
      }
    ]
  }
}

What I expected the merge the array or adding only one will work:

{
  "user_metadata": {
    "children": [
      {
        "gender": "{{fields.child1_gender}}",
        "birthdate": "{{fields.child1_birthdate}}",
        "last_name": "{{fields.child1_last_name}}",
        "first_name": "{{fields.child1_first_name}}"
      }
    ]
  }
}

Where I’m getting wrong?

Hi @c.bieber

Welcome to the Auth0 Community!

I have tested your desired outcome and I was able to store the information as you wanted to.

This is my form:


This is the flow used:

This is the code used inside the flow:

{
  "user_metadata": {
    "children": [
      {
        "last_name": "{{fields.first_last_name}}",
        "first_name": "{{fields.first_first_name}}"
      },
      {
        "last_name": "{{fields.second_last_name}}",
        "first_name": "{{fields.second_first_name}}"
      }
    ]
  }
}

This is the user_metadata inside the user profile:

{
  "children": [
    {
      "last_name": "Smith",
      "first_name": "John"
    },
    {
      "last_name": "Smith",
      "first_name": "Susan"
    }
  ]
}

Regardless of the number of steps, the data should still be available when running the flow in order to store the required data. As long as the JSON format is valid, you should be able to use an array for the user_metadata.

Let me know if you have any other questions regarding the matter.

Kind Regards,
Nik

1 Like

Hello @nik.baleca,

I found the issue why I’m struggling.

This is my form and what I’m doing is to give the user the option to skip the next step with a jump button.

I got the idea to dig into the documentation for the jump button and this is bringing up that issue because it doesn’t save the values in the form.

Any idea for that?

Hi again @c.bieber

Indeed, in the form that you have build, if you click the jump button after completing the form, it will not save the values of the fields, this appears to be expected behaviour.

For your use case, I would recommend to have the user go to the next child screen so that it saves the information and only skip from the current child’s screen.

EX: User fills in information for their second child → Hits Continue (information gets saved) → Gets redirected to Third Child Form → Clicks the Go to Overview to skip it.

Otherwise, if the information is left empty int he first two child forms and the user completes the third only, it is expected for the array elements to be empty.

If you have any other questions, let me know!

Kind Regards,
Nik