Hi, I'm making the web development course and I need to validate :

1. Add validation to the Save Action in the PersonDetail Screen that verifies that the date of birth needs to be before the current date.

2. Add a second validation to the same Save Action that verifies that the date of death, if specified, needs to be later than the date of birth.

I'm tryng like this in "Save" action, but when I input the date of birth and date of death the data still can save with error validation message. I need to be this action can't be saved if the date of birth set currently and date of death need later than the date of birth.

Can you explain a little about this? I still not understand the logic about input validation
I'm just started at this course, so if you give me a reference I'm very grateful.

Able to show the if statement you used for the diffdays?

Do take note that nulldate() is always 1900-01-01. 


Hello Ayu, 

Flash course on validation:

1. Most inputs have three properties: Valid & ValidationMessage and Mandatory. 

2. All inputs need to be bound to a variable (when submitting the inputs to the server, the inputs contents will be converted to the data type of the variables and store in them. 

3. Buttons & Links have a property that is the Validation method: None, Client & Server, Server. 

4. When you define a validation method different than None, the system will perform two validations automatically.

a) It will check all inputs that have their Mandatory property set to Yes. Any of those inputs that are empty will have its Valid property set to False and the Validation Message set to the default message for missing value. 

b) All inputs that have data defined by the user will be tested to see if what the user defined can be converted to the Data Type of the bound variable. If not, the Valid property of those inputs will be set to False and Validation Message will be set accordingly. 

5. If the inputs are inside a Form, one input that has its Valid property set to False is enough to cause the Valid Property (read only) of the Form to be also set to False. 

6. If the Validation Method is Client & Server, any invalid input (automatic validations mentioned before) will cause the request (submit) to the server to be aborted and the errors will be shown to the user. In this method, these validations are made in the browser. 

7. If the Validation Method is set to Server, the inputs will be sent to the server 'as is' and before the Screen Action starts, the two automatic validations mentioned above will happen. This means that when the screen action starts, the Valid & Validation Message properties of the Form and inputs are set. 

8. If you don't wanna to do any other validation, you should at least check in your code if the Form is valid, before doing anything. 

9. If you pretend to do any other validation, you should do them before checking the Form.Valid, as setting an Input.Valid property to False in the Screen Action will also set the Form.Valid property to False. 

10. By default we do all our personalize validations, no matter if the previous one failed or not (than the typical aspect of this part of the code you can see in the image you attached). This way we guarantee that all possible errors are checked and we inform the user about all of them at once. 

Now, about your case. 

When the e er uses asks you to validate if the Date of Death, if defined, is after the Date of Birth, you need to do something like this in your condition:

DateOfDeath <> NullDate() AND DateOfDeath < DateOfBirth

This is because when the DateOfDeath is not set by the user, the bound variable will assume the Null Date value, that is 1900-01-01. Just comparing the two dates will always cause the validation to fail in this case. 

With the image you are showing, it is not possible to happen what you are saying: "but when I input the date of birth and date of death the data still can save with error validation message" 

This is not possible because if you pass through the 'not Form.Valid' IF condition and actually saves the record, you are redirected to the People screen, so there are no way of seeing the error messages. 

If you mean that you are setting the Validation messages (there is in fact an error) but the record is being saved anyway, this means that you are probably forgetting to set the Valid property of the input that fails the validation to False. The message by itself is not enough to mark the input as invalid. 

Só, could you explain what you meant with that? 



Good Morning.

I am also new to OutSystems and in Development.

I am at the same stage as the LAB above.

As described in point 1 by Ayu, the LAB asks you to enter a validation to confirm that the date of birth is valid.

He had done the same procedure previously regarding the release date of the films, following the steps described in the LAB.

Now, when doing the procedure for the actors' birth dates, the code was wrong.

I looked in different parts of the system, but I didn't understand what happened.

The code I inserted in the IF, was as follows:

PersonForm.Record.Person.DateOfBirth> Year (CurrDate ())

and the error reported in TRUECHANGE was:

Cannot apply '>' operator to 'Date' together with 'Integer'

As I understand it, "Year (CurrDate ())" is a standard system command. I think it is also a DataType type.

So, I didn't understand why the error, since my DateOfirth variable is of type DataType.

Can you help me, please?

Should my code be different?


Hi Christian,

please don't attach new questions to existing posts.

you probably mean DateTime instead of DataType, right?

Year is a function, and the return type is integer.

so what do you want to check exactly in your validation ??

you can compare DateOfBirth to CurrDate directly, without any involvement of the year function, meaning that the actor can't be born in the future, maybe ?