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

  • 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(...)
      )
    )

  • You add those validations on the individual components like text field, dropdown field etc. And set the button's validate: true. That should get you covered. 

  • Hi,
    I have a SAIL form with attached code and also I have a process model with "Start Node" as the form.

    Now, when the user clicks on DELETE icon (red icon) with default row and clicks on Submit button, we would like to display an ERROR message and stop the form submission.

    Any advises please.

    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: {
              a!gridLayoutHeaderCell(label: "First Name" ),
              a!gridLayoutHeaderCell(label: "Last Name" ),
    
              /* For the "Remove" column */
              a!gridLayoutHeaderCell(label: "" )
            },
            /* Only needed when some columns need to be narrow */
            columnConfigs: {
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    
              a!gridLayoutColumnConfig(width: "ICON")
            },
            rows: a!forEach(
              items: local!employees,
              expression: a!gridRowLayout(
                contents: {
                  /* For the First Name Column*/
                  a!textField(
                    /* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
                    label: "first name " & fv!index,
                    value: fv!item.firstName,
                    saveInto: fv!item.firstName,
                    required: true
                  ),
                  /* For the Last Name Column*/
                  a!textField(
                    label: "last name " & fv!index,
                    value: fv!item.lastName,
                    saveInto: fv!item.lastName,
                    required:true
                  ),
                  /* For the Removal Column*/
                  a!richTextDisplayField(               
                    value: a!richTextIcon(
                      icon: "close",
                      altText: "delete " & fv!index,
                      caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          a!save(local!employees, remove(local!employees, save!value))
                        }
                      ),
                      linkStyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  )
                },
                id: fv!index
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Employee",
    
              saveInto: {
                a!save(local!employees, append(local!employees, save!value))
              }
            ),
            rowHeader: 1
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            submit: true
          )
        )
      )
    )

  • +1
    Certified Lead Developer
    in reply to swapnar6405

    Please check my reply above from yesterday evening, the thing I mentioned should cover this case, provided my assumptions were correct (you haven't really specified some important details here so i'm left to guess...)