user interface validations

Hi,

I have a form which I am using to edit a record.

I have a validation in the field like when the user tries to enter some number, I am have to ensure it is not existing. For this I have written a rule and ensuring the user is not enter the existing number.

The issue here is,  the validation is firing in the page load itself. I was expecting it will fire when I star editing the content in the field.

Any solution to this please.

code:

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Hi,

    This is my understanding, ex: you submitted a new request with a filed (Ex: Property Number) value as 123, this filed have a validation to make sure user is not entering a property number value which is already in the system. I think the issue you are facing after submitting the request, when you try to edit the same request by default it is throwing validation error, since your validation checks the current value against the data base values (Here your expectation is  we shouldn't show validation message since this is an existing request and user didn't modify the value). If this is what you are issue is, You need to update your validation logic to skip validation if it is an existing request and user didn't modify any value

    Try this logic, it should work.

    a!localVariables(
      local!initialValue: a!refreshVariable(
        /*save your rule input value here on load*/
        value: ri!propertyNumber,
        refreshOnReferencedVarChange: false
      ),
      /*Existing number to compare - */
      local!existingNumbers: {345, 678, 199},
      {
        a!textField(
          label: "Property Number",
          value: ri!propertyNumber,
          saveInto: ri!propertyNumber,
          validations: {
            if(
              and(
                a!isNotNullOrEmpty(ri!propertyNumber),
                local!initialValue <> ri!propertyNumber,
                contains(local!existingNumbers, ri!propertyNumber)
              ),
              "This ID is exist",
              ""
            )
          }
        )
      }
    )

Reply Children
No Data