Error message coming multiple times

Hi ,

I am checking name field in table TestDataSetIdByName . As per my requirement if entered name is already exists in table then it should display one error message.

But issue is we have requirement like already we have junk data which we can't remove but we need to add new validation for adding any new name. If that is available then this validation should work.  

Suppose i am entering name is "Appian" which is already in table 3 times , then this validation rule is displaying error message three times which is not expected , it should display only one time.

What is work around for that. PFA code also.

load(
  local!name,
  local!selectedButton,
  a!formLayout(
    contents: {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!sectionLayout(
                contents: {
                  a!columnsLayout(
                    columns: {
                      a!columnLayout(
                        contents: {
                          a!textField(
                            label: "Name",
                            required: true(),
                            labelPosition: "ADJACENT",
                            value: ri!TestDataSet.name,
                            saveInto: ri!TestDataSet.name
                          ),
                          
                        }
                      )
                    }
                  )
                }
              )
            }
          )
        }
      )
    },
    validations: {
      if(
        and(
          local!selectedButton = "add",
          local!name <> ri!TestDataSet.name
        ),
        if(
          tointeger(
            rule!TestDataSetIdByName(
              ri!TestDataSet.name
            )
          ) >= 1,
          a!validationMessage(
            message: "This name already exists, please enter a different name.",
            validateAfter: "REFRESH"
          ),
          {}
        ),
        {}
      )
    }
  )
)

Please ignore  unnecessary syntax as i have to  filter rest of company code .

  Discussion posts and replies are publicly visible