Required Textfield in the editable grid validation not working properly

Certified Associate Developer

Hi All,

i have editable grid in my ui, on that i have textfield which i marked as required. (note: when page loads grid is disabled based on the button action grid will get enabled).

but i have couple of validation for that textfield  that is working but with respective to required condition it is not working. please find below the screenshot and code snippet. Kindly help me on the same.

a!textField(
                          label: "Dental Members",
                          labelPosition: "ABOVE",
                          value: fv!item.dentalEnr,
                          saveInto: {
                            fv!item.dentalEnr,
                            if(
                              contains(
                                touniformstring(index(local!editList, "intakeId", null)),
                                tostring(fv!item.intakeId)
                              ),
                              {
                                a!save(
                                  local!editList,
                                  remove(
                                    local!editList,
                                    wherecontains(
                                      tostring(fv!item.intakeId),
                                      touniformstring(index(local!editList, "intakeId", null))
                                    )
                                  )
                                ),
                                a!save(
                                  local!editList,
                                  append(local!editList, fv!item)
                                )
                              },
                              a!save(
                                local!editList,
                                append(local!editList, fv!item)
                              )
                            )
                          },
                          refreshAfter: "UNFOCUS",
                          showWhen: if(
                            local!region = cons!GSE_SCL_TXT_REGIONS[4],
                            contains(
                              local!showinsureTechColumns,
                              "dentalEnr"
                            ),
                            contains(
                              local!showOtherRegionColumns,
                              "dentalEnr"
                            )
                          ),
                          required: if(
                            a!isNullOrEmpty(fv!item.dentalPremium),
                            false,
                            true
                          ),
                          disabled: if(
                            not(
                              contains(
                                touniformstring(local!editMode),
                                tostring(fv!item.intakeId)
                              )
                            ),
                            true,
                            if(
                              a!isNullOrEmpty(fv!item.dentalPremium),
                              true,
                              false
                            )
                          ),
                          validations: {
                            rule!GSE_SCL_checkNumbersOnlyValidation(
                              searchString: fv!item.dentalEnr,
                              checkMinValue: false
                            ),
                            if(
                              and(
                                a!isNullOrEmpty(fv!item.dentalPremium),
                                a!isNotNullOrEmpty(fv!item.dentalEnr)
                              ),
                              "This field must be left blank if Dental Premium (Annual) is not provided.",
                              
                              if(
                                and(
                                  a!isNotNullOrEmpty(fv!item.dentalPremium),
                                  a!isNullOrEmpty(fv!item.dentalEnr)
                                ),
                                "This field required if dental premium has value ",
                                null
                            ))
                          }
                        ),

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Couple of tips to help troubleshoot:

    • It appears that everything about your data is based upon text rather than numbers, even though the user is supposed to enter a number. Double check that there aren't whitespace characters in the values provided. You might need a trim() call, or better yet, ensure the data model has integers defined for these fields rather than text. You can also avoid the need to validate that a string is a number by using the integerField component, so long as your use case is within integerField limitations.
    • We need more context to understand why validation on the top row has fired to begin with, which may help us understand why the bottom row did not fire. A screenshot that shows us what the grid looks like when not globally disabled should help us with some additional context.
    • The text field's required parameter definition already handles what your validation is attempting to handle. To use your custom message with it, simply pass in the requiredMessage parameter.
Reply
  • 0
    Certified Lead Developer

    Couple of tips to help troubleshoot:

    • It appears that everything about your data is based upon text rather than numbers, even though the user is supposed to enter a number. Double check that there aren't whitespace characters in the values provided. You might need a trim() call, or better yet, ensure the data model has integers defined for these fields rather than text. You can also avoid the need to validate that a string is a number by using the integerField component, so long as your use case is within integerField limitations.
    • We need more context to understand why validation on the top row has fired to begin with, which may help us understand why the bottom row did not fire. A screenshot that shows us what the grid looks like when not globally disabled should help us with some additional context.
    • The text field's required parameter definition already handles what your validation is attempting to handle. To use your custom message with it, simply pass in the requiredMessage parameter.
Children
No Data