Form validation not working on SUBMIT

I have a form with a selectable read-only grid

The form contains complex validation for the grid where if a row was already selected before it cannot be selected again and submitted.

Optimistic Locking.

Now the validation works like a charm upon any interaction with the form except the SUBMIT button

I have exausted my imagination with trying to make it work:

  1. Putting the validation in the grid
  2. Putting the validation in the form
  3. creating validation groups
  4. Add a confirmation message after submit
  5. etc

I only use up to date interface components and the SUBMIT button obviously has skipValidation: false

here's a look at what I tried for the button

a!buttonWidgetSubmit(
          label: "SUBMIT",
          value: "SUBMIT",
          saveInto: {},
          style: "PRIMARY"
          /*,
          confirmHeader: "bob",
          confirmButtonLabel: "concurency pass?",
          */
          /*skipValidation: false*/
        )

Here's a look at the validation

    validations: {
      a!validationMessage(
        message: if(
          rule!isIntersection(
            array: ri!value,
            value: local!concurency
          ),
          "concurency",
          null
        )/*"concurency"*/,
        /*showWhen: rule!isIntersection(
          array: ri!value,
          value: local!concurency
        ),*/
        validateAfter: "REFRESH"/*"SUBMIT"*/
      )
    }

I'm concidering to open a ticket with APPIAN because I think the fault is on their end

EDIT:

Added full generic form (I chared what I can it's confidential): 

with(
  local!data: rule!getData(),
  local!report: rule!getActiveProcesses(),
  local!concurency: rule!whereContains(local!data,local!report),
  a!formLayout(
    label: "label",
    contents: {
      a!sectionLayout(
        label: "Customers for Review",
        contents: {
          a!gridField(
            label: "Read-only Grid",
            labelPosition: "ABOVE",
            data: local!data,
            columns: {
              a!gridColumn(
                label: "A",
                sortField: "A",
                value: fv!row.A
              )
            },
            pagesize: 20,
            selectable: true,
            selectionStyle: "CHECKBOX",
            selectionValue: {
              ri!value
            },
            selectionSaveInto: ri!value,
            disableRowSelectionWhen: {},
            validations: {}
          )
        }
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidgetSubmit(
          label: "SUBMIT",
          value: "SUBMIT",
          saveInto: {
            ri!action,
            
          },
          style: "PRIMARY",
          skipValidation: false
        )
      },
      secondaryButtons: {}
    ),
    validations: {
      a!validationMessage(
        message: if(
          rule!isIntersection(
            array: ri!value,
            value: local!concurency
          ),
          "concurency",
          null
        ),
        /*showWhen: rule!isIntersection(
          array: ri!value,
          value: local!concurency
        ),*/
        validateAfter: "REFRESH"
      )
    }
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    It may sound incredibly stupid, but to rule out any logical inconsistency, try replacing the boolean expression in your message:  with if(TRUE and if(FALSE to see how it behaves when it interprets what you're sending as true or false.

    Next, you could try using a temporary textField set to readOnly that displays the result of rule!isIntersection on the textField when you press that button.  It's possible that you have an error in your logic that's causing that rule to ALWAYS return false or ALWAYS return true.

    I also wonder about using the showWhen input.  That shouldn't be necessary.  Remember that your validation is simply a string.  If the string has any contents, those are displayed and submit fails.  If it doesn't have any contents, it's null or the empty string, it doesn't have anything to show and submit continues.  Giving it any string contents or not is enough.  ShowWhen doesn't need to come into play, and that might also be messing you up.  See if it works without it.  Or you could change the strings from empty and some other thing to "Should submit" and "Should not submit".  The validation on the screen will tell you if the logic is working.  It will tell you if it's somehow backwards.  After those are looking right, then you can switch the one back to nothing to see if it submits after that.

    Showing Appian that you've exhausted all possibility of it being on your end I'm sure goes a long way toward your support ticket.

  • The think is, I already tried all these different debugging alternatives. It works how it's supposed to if you press literally any interface component on the page. Really the only problem is the SUBMIT button which simply ignores the validation for an unknown reason. 

  • 0
    Certified Lead Developer
    in reply to mikels0001

    Can you post a whole-form example which reproduces this issue, generalized enough that anyone reading this could paste it into a blank interface designer window and help troubleshoot?  Otherwise to be honest, there's a bit too much guesswork with respect to the parts of the form code you haven't included above, such as what (if any) local variables you've set up that affect this, how they're configured, etc.

  • What happens if you hardcode a message in (instead of your if statement)? Like if you put "concurrency" directly in your message, does it show that?

    Also, did you test this in an actual form or only in Interface Designer? Sometimes it's hard to tell if the form validates or not without trying a real task to see if it submits.

  • Hey Peter,

    Great having you here.

    1. When I hardcode the message as shown below it works.

     

        validations: {
          a!validationMessage(
            message: 
            "concurency"
            /*if(*/
              /*rule!isIntersection(*/
                /*array: ri!value,*/
                /*value: local!concurency*/
              /*),*/
              /*"concurency",*/
              /*null*/
            /*)*/
            ,
            /*showWhen: rule!isIntersection(
              array: ri!value,
              value: local!concurency
            ),*/
            validateAfter: "REFRESH"
          )
        }

    2. Yes I tested in an actual form (an excessive number of times hoping it will work) that's how I discovered the problem. The interface Designer has weird behavior when I test.

  • Interesting - so it does validate on the submit button in some cases. What does the rule isIntersection return? Can you share that expression?

  • rule!isIntersection()

    if(
      or(
        rule!isBlank(
          ri!array
        ),
        rule!isBlank(
          ri!value
        )
      ),
      false,
      not(
        rule!isBlank(
          intersection(
            ri!array,
            ri!value
          )
        )
      )
    )

    It's basically a true/false and null safe version of intersection() but for only 2 parameters

Reply Children
No Data