Skip to main content
May 23, 2022
Question

Dob field

  • May 23, 2022
  • 2 replies
  • 0 views

Hi,

My question is , in interface design to edit a expression level, to enter a dob automatically to display a age field??? Is it possible give me a solution

    2 replies

    mikes0011
    Brainy
    May 23, 2022

    Sorry, I'm having a lot of trouble understanding what you're trying to ask here.  My only guess is, you're asking if a user can enter a DOB, and then once it's populated, an Age value will be shown elsewhere on the same interface?  Please confirm if this is close, and if so, I can help show you how this would be implemented.

    The Expression Guru
    Inspiring
    May 23, 2022

    Hi,

    As mike mentioned in your question you haven't provided much details. I am guessing this is what you are looking for.

    a!localVariables(
      local!dob,
      local!age,
      {
        a!dateField(
          label:  "DOB",
          value: local!dob,
          saveInto: {
            local!dob,
            a!save(
              local!age,
              if(
                a!isNullOrEmpty(local!dob),
                null,
                int(tointeger(tointervalds(today()) - tointervalds(local!dob))/365)
              )
            )
          }
        ),
        a!textField(
          label: "Age",
          value: local!age,
          readOnly: true
        )
      }
    )