Dynamically add mobile number

how should i approach from appian side ... to add mobile number dynamically ..

For now i am having  blank text field where user can enter mobile number.. next to it i want to provide add button .. so whenever it gets clicked a new text field should appear to add new mobile number with validation ... 

a!localVariables(

  local!add ,
  local!npi,
  a!sideBySideLayout(
    items: {
      a!sideBySideItem(
        item: a!textField(
          label: "Mobile Number",
          labelPosition: "ABOVE",
          value: local!npi,
          saveInto: local!npi,
          validations: if(
            a!isNullOrEmpty(local!npi),
            {},
            if(
              not(
                regexmatch("^([0-9]{" & 10 & "})$", local!npi)
              ),
              "Maximum " & 10 & " digits are allowed",
              ""
            )
          )
        )
      ),
      a!sideBySideItem(
        item: a!linkField(
          label: "",
          links: {
            a!dynamicLink(
              label: "add new ",
              value: true(),
              saveInto: local!add 
            )
          }
        )
      )
    },
    
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hii, Klaus34
    you can try this

    a!localVariables(
      local!npi:{
        {
          mobileNo:""
        }
      },
      a!columnsLayout(
        columns:{
          a!columnLayout(
            contents: a!forEach(
              items: local!npi,
              expression:  a!textField(
                label: "Mobile Number",
                labelPosition: "ABOVE",
                value: fv!item.mobileNo,
                saveInto: fv!item.mobileNo,
                validations: if(
                  a!isNullOrEmpty(fv!item.mobileNo),
                  {},
                  if(
                    not(
                      regexmatch("^([0-9]{" & 10 & "})$", fv!item.mobileNo)
                    ),
                    "Maximum " & 10 & " digits are allowed",
                    ""
                  )
                )
              )
            )
          ),
          a!columnLayout(
            contents: a!linkField(
              label: "",
              links: {
                a!dynamicLink(
                  label: "add new ",
                  value: {
                    mobileNo:""
                  },
                  saveInto: a!save(local!npi,append(local!npi,save!value))
                )
              }
            )
          )
        }
      )
    )

  • thanks it helped .. can we do by comma separated in one text field only ??

    Like this 1234567890, 1234567890 with validation  of 10 digits .. while saving i will iterate by a! for each

Reply Children
  • 0
    Certified Associate Developer
    in reply to Klaus34

    no, in one text field, you cannot add multiple numbers, but you can do it by using a text field  in side by side layout,

    a!localVariables(
      local!npi:{
        {
          mobileNo:""
        }
      },
      a!sideBySideLayout(
        items: {
          a!forEach(
            items: local!npi,
            expression: a!sideBySideItem(
              item: a!textField(
                label: "Mobile Number",
                labelPosition: "ABOVE",
                value: fv!item.mobileNo,
                saveInto: fv!item.mobileNo,
                validations: if(
                  a!isNullOrEmpty(fv!item.mobileNo),
                  {},
                  if(
                    not(
                      regexmatch("^([0-9]{" & 10 & "})$", fv!item.mobileNo)
                    ),
                    "Maximum " & 10 & " digits are allowed",
                    ""
                  )
                )
              )
            )
          ),
          a!sideBySideItem(
            item: a!linkField(
              label: "",
              links: {
                a!dynamicLink(
                  label: "add new ",
                  value: {
                    mobileNo:""
                  },
                  saveInto: a!save(local!npi,append(local!npi,save!value))
                )
              }
            )
          )
        }
      )
    )