Empty grid validation message

i,
I have a grid inside a form with "Submit" and "Cancel" button, where I am loading one row with required entry fields.
Also there is an delete icon basides to that row to delete.

Now, when I try to submit the form in the browser url by clicking "Submit" button, system is not locaing validation message which is there at grid/form level.
Whereas validation message is firing during interface level testing.

Any inputs on this please.
TIA

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Are you saying you want there to be a validation shown if the user tries to submit an empty Grid, and your current validations are row-level (and thus not shown when no rows are present)?

    If my guess above is correct - I suggest you look into section-level validations, and utilize a!validationMessage() (which you can set to fire at submit time), and its condition will check whether no data rows are present.

    Edit: I forgot, a!validationMessage() is also valid in an Editable Grid, which is perfect for this use case.  Thanks for providing your code below, here's the same but with my small addition:

    a!localVariables(
    
      local!employees: {
        a!map( id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 ),
      },
      a!formLayout(
        label: "Add or Update Employee Data",
        instructions: "Add, edit, or remove Employee data in an inline editable grid",
        contents: {
          a!gridLayout(
            totalCount: count(local!employees),
            headerCells: {...},
            /* Only needed when some columns need to be narrow */
            columnConfigs: {...},
            rows: a!forEach(...),
            addRowlink: a!dynamicLink(...),
            rowHeader: 1,
            
            /* ADDED VALIDATION PARAMETER */
            validations: {
              a!validationMessage(
                message: "At least one row is required.",
                showWhen: a!isNullOrEmpty(local!employees),
                validateAfter: "SUBMIT"
              )
            }
            
            
          )
        },
        buttons: a!buttonLayout(...)
      )
    )

Reply
  • 0
    Certified Lead Developer

    Are you saying you want there to be a validation shown if the user tries to submit an empty Grid, and your current validations are row-level (and thus not shown when no rows are present)?

    If my guess above is correct - I suggest you look into section-level validations, and utilize a!validationMessage() (which you can set to fire at submit time), and its condition will check whether no data rows are present.

    Edit: I forgot, a!validationMessage() is also valid in an Editable Grid, which is perfect for this use case.  Thanks for providing your code below, here's the same but with my small addition:

    a!localVariables(
    
      local!employees: {
        a!map( id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 ),
      },
      a!formLayout(
        label: "Add or Update Employee Data",
        instructions: "Add, edit, or remove Employee data in an inline editable grid",
        contents: {
          a!gridLayout(
            totalCount: count(local!employees),
            headerCells: {...},
            /* Only needed when some columns need to be narrow */
            columnConfigs: {...},
            rows: a!forEach(...),
            addRowlink: a!dynamicLink(...),
            rowHeader: 1,
            
            /* ADDED VALIDATION PARAMETER */
            validations: {
              a!validationMessage(
                message: "At least one row is required.",
                showWhen: a!isNullOrEmpty(local!employees),
                validateAfter: "SUBMIT"
              )
            }
            
            
          )
        },
        buttons: a!buttonLayout(...)
      )
    )

Children
No Data