Validations

  

If validation is selected as both client and server then, mandatory check and

data type check is not done at server side?

Hi Lovish,

In both validation methods, "Client & Server" and "Server", the page will perform the standard valiadtion in the client (browser): Wrong Data Type and Missing Mandatory Value

The difference is that in the first case ("Client & Server"), the javascript that does this validation will not call the screen action. Instead, it will mark the wrong inputs (usually red border) and set the standard validation messages and warn the user.

In the second case ("Server"), thos two steps, set the input/form valid to false and set the standard message will ALSO be performed, but you need explicit logic in the action (that will be called), to check if the form is valid or not (the form Valid property will be set to False if there is something wrong).

Cheers,
Eduardo Jauch

P.S. Remember to mark the correct answers (even in previous questions), or improve the question if the answer is not sactisfactory or you didn't understood something.  

Eduardo Jauch wrote:

Hi Lovish,

In both validation methods, "Client & Server" and "Server", the page will perform the standard valiadtion in the client (browser): Wrong Data Type and Missing Mandatory Value

The difference is that in the first case ("Client & Server"), the javascript that does this validation will not call the screen action. Instead, it will mark the wrong inputs (usually red border) and set the standard validation messages and warn the user.

In the second case ("Server"), thos two steps, set the input/form valid to false and set the standard message will ALSO be performed, but you need explicit logic in the action (that will be called), to check if the form is valid or not (the form Valid property will be set to False if there is something wrong).

Cheers,
Eduardo Jauch

P.S. Remember to mark the correct answers (even in previous questions), or improve the question if the answer is not sactisfactory or you didn't understood something.  


so it means by applying form.valid we are also checking mandatory and data type , if validation is ' Client and Server'?

If Validation is Client & Server, the server will not be called if the two automatic validations fail in any input.

If the Validation is "Server" and any input fails the data type or missing mandatory data validations, the input valid property and the form valid property will be marked with false and the screen action will be called

In this case, you must check at least the Valid property of the form to see if something failed and continue or not the execution depending on the value you find in the form valid (usually you stop the action at this point).

Cheers,
Eduardo Jauch

Hi Lovis,

If you set validation type client and server for any action then validation will applied automatically at client side for inputs which are mandatory but for server side you have to write your own logic to like as "textbox.vaid" if it returns false then you need to call action "Input_FocusFirstInvalid" in this way you can perform server side validation.


Regards

-SK-

Hi Lovis,

If you still having confusion please let me know I can create a sample OML for you.


Regards

-SK-

Eduardo Jauch wrote:

Hi Lovish,

In both validation methods, "Client & Server" and "Server", the page will perform the standard valiadtion in the client (browser): Wrong Data Type and Missing Mandatory Value

The difference is that in the first case ("Client & Server"), the javascript that does this validation will not call the screen action. Instead, it will mark the wrong inputs (usually red border) and set the standard validation messages and warn the user.

In the second case ("Server"), thos two steps, set the input/form valid to false and set the standard message will ALSO be performed, but you need explicit logic in the action (that will be called), to check if the form is valid or not (the form Valid property will be set to False if there is something wrong).

Cheers,
Eduardo Jauch

P.S. Remember to mark the correct answers (even in previous questions), or improve the question if the answer is not sactisfactory or you didn't understood something.  

Just mark this as the right answer. Good explanation! By default, the intelliwarp will generate a page with a server side validation and in the screen action will add an If to validate the form (at least at the 9.1 version).

Validation Example:


- Name type check;

- Address mandatory attribute check;

- Address type check;

The none will not run any javascript validation. But Outsystems, in the version 9.1, doesn't remove the injected validation scripts from the page. It would be nice to have that optimizated to decrease the Doc size (Maybe they have a reason for it).

Regards


Hi All, 


Thank you for the explanations. 


I need suggestions on implementation of the same. I have selected the validation to be client and server and I prefer performing the server side validations in a server action instead of a screen action( I will pass my input from the screen into the server action to perform the validations). 

In this case, will there be an option to still check form.valid ( since form details will not be available in server actions). I'm just wondering if there is any alternative.Kindly suggest if any.


Thanks and Regards,

Priya




Hello Priyadharshini

Server actions can't access anything from web screens and vice-versa.
As validations (imho) are an "interface" thing, not business logic, I prefer to do all the extra validations in the screen action. 

If you put in a server action because you will do this in more than one place, than probably what you really should have done is to use a web block for the inputs.

If this is not possible (because only part of the form will be the same), than you have to duplicate code (yeah, I know, it sucks), or you have to come up with some kind of strategy to return from the server action which controls failed and the error messages, what will be worst, imho.

In the end, my recommendation is: don't do the validation in a server action. Do in the screen action that receive the inputs.

Cheers.

Hi Eduardo,


Thank you for the options. It was helpful.


Thanks and Regards,

Priya