Want to add Dynamic Mobile number

as i have written the following code .. but how to increase the index.. i

if user clicks on add new .. new field of mobile number should get added..

a!localVariables(

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

  Discussion posts and replies are publicly visible

Parents
  • Initialize the local variable

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

  • below code doesnt add new field i dnt know whats the issue.can u check pls

    a!columnLayout(
      contents: a!localVariables(
        local!phone: if(a!isNullOrEmpty(ri!editGrid.lead.phone)," ",ri!editGrid.lead.phone),
    
        a!columnsLayout(
          columns: a!columnLayout(
            contents: {
              a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                value: {
                  a!richTextItem(
                    text: "Phone",
                    style: "STRONG"
                  )
                }
              ),
              a!forEach(
                items: local!phone,
                expression: {
                  a!sideBySideLayout(
                    items: {
                      a!sideBySideItem(
                        width:"10X",
                        item: a!textField(
                          label: cons!PRO_TXT_LABEL_PHONE & " " & fv!index,
                          labelPosition: "COLLAPSED",
                          placeholder: "-Enter Phone Number-",
                          value: fv!item,
                          saveInto: {fv!item,
                          a!save(local!phone,fv!item)},
    
    
                          refreshAfter: "UNFOCUS",
                          validations: {},
    
                        )
                      ),
                      a!sideBySideItem(
                        item: a!richTextDisplayField(
                          labelPosition: "COLLAPSED",
                          value: {
                            a!richTextIcon(
                              icon: "times",
                              altText: "Remove number",
                              link: a!dynamicLink(
                                saveInto: a!save(
                                  local!phone, remove(local!phone, fv!index)
                                )
                              ),
                              linkStyle: "STANDALONE"
                            )
                          },
                          showWhen: count(local!phone) > 1
                        ),
                        width: "AUTO"
                      )
                    },
                    alignVertical: "MIDDLE"
                  )
                }
              ),
              a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                value: a!richTextItem(
                  text: {
                    a!richTextIcon(
                      icon: "plus",
                      altText: "plus"
                    ),
                    " ",
                    "Add phone number"
                  },
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!phone, append(local!phone, ""))
                    }
                  ),
                  linkStyle: "STANDALONE"
                ),
                accessibilityText: "Clicking this link will add another phone number input above."
              )
            },
            width: "NARROW_PLUS"
          )
        )
      )
    )

Reply
  • below code doesnt add new field i dnt know whats the issue.can u check pls

    a!columnLayout(
      contents: a!localVariables(
        local!phone: if(a!isNullOrEmpty(ri!editGrid.lead.phone)," ",ri!editGrid.lead.phone),
    
        a!columnsLayout(
          columns: a!columnLayout(
            contents: {
              a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                value: {
                  a!richTextItem(
                    text: "Phone",
                    style: "STRONG"
                  )
                }
              ),
              a!forEach(
                items: local!phone,
                expression: {
                  a!sideBySideLayout(
                    items: {
                      a!sideBySideItem(
                        width:"10X",
                        item: a!textField(
                          label: cons!PRO_TXT_LABEL_PHONE & " " & fv!index,
                          labelPosition: "COLLAPSED",
                          placeholder: "-Enter Phone Number-",
                          value: fv!item,
                          saveInto: {fv!item,
                          a!save(local!phone,fv!item)},
    
    
                          refreshAfter: "UNFOCUS",
                          validations: {},
    
                        )
                      ),
                      a!sideBySideItem(
                        item: a!richTextDisplayField(
                          labelPosition: "COLLAPSED",
                          value: {
                            a!richTextIcon(
                              icon: "times",
                              altText: "Remove number",
                              link: a!dynamicLink(
                                saveInto: a!save(
                                  local!phone, remove(local!phone, fv!index)
                                )
                              ),
                              linkStyle: "STANDALONE"
                            )
                          },
                          showWhen: count(local!phone) > 1
                        ),
                        width: "AUTO"
                      )
                    },
                    alignVertical: "MIDDLE"
                  )
                }
              ),
              a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                value: a!richTextItem(
                  text: {
                    a!richTextIcon(
                      icon: "plus",
                      altText: "plus"
                    ),
                    " ",
                    "Add phone number"
                  },
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!phone, append(local!phone, ""))
                    }
                  ),
                  linkStyle: "STANDALONE"
                ),
                accessibilityText: "Clicking this link will add another phone number input above."
              )
            },
            width: "NARROW_PLUS"
          )
        )
      )
    )

Children
No Data