Validations on child interface

Hi, 

I have the following case:

- interface that is built with one large main boxLayout which has 5 boxLayouts inside it and 1 buttonLayout (sectionLayouts and formLayouts are not option AFAIK because this interface must be child interface)

- there are some casual "required property" validations and some with more complex calculations

- "required" validations are present in all 5inner boxLayouts and this complex one is present in the last boxLayout (last boxLayout contains a gridLayout and these validations are regarding SUM of values in grid rows and chronological order of the dates in the grid rows)

- I need to perform these validations ONLY on a click of a button in the last part of the initial boxLayout

- this button is NON submit and it saves values to 4 rule input CDTs and finally starts a process with a!startProcess

- this interface is child interface of the existing parent interface (it is embedded inside one of its columnLayouts)

a!boxLayout(
  contents:
  {
    
    a!boxLayout(),  /*text fields and date pickers with REQUIRED*/
    a!boxLayout(),  /*child interface with editable grid with REQUIRED*/
    a!boxLayout(),  /*child interface with editable grid with REQUIRED*/
    a!boxLayout(),  /*text fields and date pickers with REQUIRED*/
    a!boxLayout(),  /*editable grid with REQUIRED and COMPLEX validations*/
    a!buttonLayout() /*non submit button that saves into rule inputs and starts a process which returns value to the interface*/
   }
  
)

I am trying to achieve the logic where all the validations on the child interface are performed ONLY when button is clicked and without any interference with other validations of the parent interface (clicking of the button inside child interface performs all the other validations for some reason).

I've been trying to achieve this with multiple combinations of validate flag, validation group and validateAfter properties, but nothing works. Some of child interface validations are not performed upon clicking the button and validations of the parent form prevent process from starting even though this child interface should not be blocked by missing data on parent interface.

Could anyone give me some more detailed  instructions how to make it sure that validations are performed only in the way I've described above?

It doesn't look to complicated as use case, but these validations are pretty confusing for me as they usually don't work as I expect :)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Took a minute, but I think I have it.  Make the button save true into a "checkValidations" boolean (local or rule input).  Have each of the individual validations on the various other components check:

    if (

    and(local!checkValidations, /*insert normal validation conditions here*/), 

    "Validation Message",

    ""

    )

    Since both need to be true, you need to pop the validation AND to have pressed the button at some point.

    You may also want to consider adding a save() into the saveInto: parameter of all the other components to set checkValidations back to false, assuming that you need to press the button again with no validations going off before you do the subprocess.

    The real tricky thing that you may have some work solving is how to prevent the startProcess from starting until all conditions are as you want them.

  • 0
    A Score Level 1
    in reply to Dave Lewis

    I've managed to resolve problem with complex validations with the code below:

    a!boxLayout(
      contents:
      {
        
        a!boxLayout(),  /*text fields and date pickers with REQUIRED*/
        a!boxLayout(),  /*child interface with editable grid with REQUIRED*/
        a!boxLayout(),  /*child interface with editable grid with REQUIRED*/
        a!boxLayout(),  /*text fields and date pickers with REQUIRED*/
        a!boxLayout(
         contents: {
            a!gridLayout(
                validations: /*complex validations*/
                validationGroup: "START_PROCESS")
            }
        ),  /*editable grid with REQUIRED and COMPLEX validations*/
        a!buttonLayout(
            primaryButtons: {
                a!buttonWidget(
                    validate: true,
                    validationGroup: "START_PROCESS"
                )    
            }
        ) /*non submit button that saves into rule inputs and starts a process which returns value to the interface*/
      }
      
    )

    Issue that remains and that I don't believe is covered in your proposition is the fact that required fields are checked even in the parent interface (e.g. some document upload field) upon clicking the button inside the child interface.

    I want validations upon required items inside the boxLayouts inside the child interface, but I don't want button in child interface to validate required fields in the parent interface.

    My child interface needs some inputs from the parent interface but otherwise should have no connections back to the parent interface nor validations "cross-check".

    Is there a way to isolate the validations inside the child interface and prevent them from triggering validations on parent interface?

  • 0
    Certified Lead Developer
    in reply to ivanm0004

    I think you could try my pattern in there as well.  Make the child button turn validations off while a button on the parent turns parent validations on, which probably also has to turn childValidations off.

    I would have to run a good number of tests to be absolutely sure that it works, but I think the saveInto of the button should be fine as long as the button doesn't have any validations that have to fire.

    Then, if it's just way too hard otherwise, there's always KLUDGING your way out with red Rich Text.

  • 0
    A Score Level 1
    in reply to Dave Lewis

    Thx for the advice, I will try that approach. Sometimes, I have the feeling that "there must be more elegant way" but, on the other hand, I do not have even one full year of experience in working with Appian :)

    Still it's pretty strange that child interface button triggers the validations on parent interface...

  • +1
    Certified Lead Developer
    in reply to ivanm0004

    There is nothing like parent and child here. At least not for validations as these are evaluated on the final flat structure.

    But I understand. Proper use of validations in complex UI takes a bit of practice. I would try to make such an interface more simple. But I do not know any of your requirements.

Reply Children
No Data