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

Parents Reply
  • +1
    A Score Level 1
    in reply to sauravk

    As per your requirement " As per my requirement if entered name is already exists in table  then it should display one error message." 

    This suggests you are querying from DB to check if name already exists. use Paging while you query and put batch size as 1. 

    I guess this is the rule where paging is needed 

    rule!TestDataSetIdByName(
    ri!TestDataSet.name
    )

Children