The ValidationTest screen needs to trigger validation for the entire form inside the ValidationForm block when the user clicks the Save button.
The current approach uses a boolean flag called IsValidate within the form data. The block detects changes to this flag through OnParametersChanged and then triggers validation.
Components
Structure: ValidationValues
ValidationTest screen
ValidationForm block
Execution Flow
Problems with the Current Approach
1. Control flags are mixed with business data.
IsValidate is a trigger signal, not actual form data, but it is stored in the same structure as the business data.
2. Poor scalability with multiple blocks.
When adding more blocks to the screen, each block requires its own flag and an additional assignment in SaveOnClick.
If a flag is forgotten, that block will not be validated, and there is no error or warning to indicate that validation was skipped.
Impact
Alternative Approach Under Consideration
I am considering another approach:
When the user clicks the Save button, JavaScript would dispatch a custom event on the window object. All blocks on the screen would listen for this event and trigger their own validation logic when they receive it.
Are there any better or more efficient approaches you would recommend, apart from the two approaches described above?
Thank you for your suggestions!Raid
Hi @Nguyen Trung ,Have you seen this post - https://www.outsystems.com/forums/discussion/89976/input-inside-of-block-inside-of-form-does-not-invalidate-the-form/https://www.outsystems.com/forums/discussion/69285/reactive-form-built-in-validation-inside-block-doesnt-work/https://www.outsystems.com/forums/discussion/52524/validation-of-a-form-made-up-from-multiple-web-blocks/Hope this earlier solution will work for you.
thank you @Deepa Tiwari , i'll check them
Hi,
I think a better approach would be to keep the validation logic inside each block while managing the overall validation flow from the parent screen.
For example:
Each block should have its own Validate Client Action.
The parent screen should trigger validation for all blocks when the Save button is clicked.
Each block should return whether its fields are valid or not.
Proceed with the server-side save only if all blocks pass validation.
This avoids maintaining separate flags like IsValidate or relying on input parameter changes to trigger validation.
Also, I'd suggest setting the Mandatory property to True for required form fields. OutSystems will automatically handle the required-field validation and highlight invalid fields in red, reducing the need for custom validation logic.
This would make the overall implementation cleaner, easier to maintain, and more scalable as new blocks are added.
Also must visit - https://www.outsystems.com/forums/discussion/52524/validation-of-a-form-made-up-from-multiple-web-blocks/
thank you @Niteesh yadav , let me try it