Hi,

I created a web submission form that must be filled in, I've problem when I create validation. 

I've DateOfIncident field, so this submission form is limited to max 3 months after the DateOfIncident

Like:

Diffdays(exForm.record.ex.DateIncident, < 90)

 I tried and got error

Thanks


Hi Ayu,

I think you need this:

 DiffDays(exForm.Record.Ex.DateIncident, CurrDate()) < 90


DiffDays(dt1,dt2) needs two dates (or datetimes) and outputs the difference in the number of days between them. 

When using the Expression editor, selecting a function (like DiffDays) shows a really good description of how to use that function, including what parameters to pass to it to avoid future errors.

Monique de Vos wrote:

Hi Ayu,

I think you need this:

 DiffDays(exForm.Record.Ex.DateIncident, CurrDate()) < 90


DiffDays(dt1,dt2) needs two dates (or datetimes) and outputs the difference in the number of days between them. 

When using the Expression editor, selecting a function (like DiffDays) shows a really good description of how to use that function, including what parameters to pass to it to avoid future errors.

Hi Monique, Thanks for the reply

I tried the syntax, but the error not show. So the form submission can be submited without any error

Hi Ayu,


I'm assuming you are setting the DateOfIncident input fields Valid and ValidationMessage properties in the assign flowing from the True Branch of your If.  


In that case, I think the expression should have >90 instead of <90 at the end of it.

Dorine

Hi Ayu,

First, what do you have in the last IF (that checks the Form Valid property)?

Because if it is something like YourFormName.Valid, then you are saying if the form is wrong, it will go down (False branch) and so, even with error it will save the record.

But as it was said, if having a difference in dates bigger than 90 days is a problem, than your validation is wrong as well.

Cheers.

Dorine Boudry wrote:

I'm assuming you are setting the DateOfIncident input fields Valid and ValidationMessage properties in the assign flowing from the True Branch of your If.  


In that case, I think the expression should have >90 instead of <90 at the end of it.

Yeah, that or swap connections on validation IF's.

Also you'd probably want to validate that accident date is actually in the past and not in the future, means DiffDays() should be >= 0 and <90

Dorine Boudry Eduardo Jauch Vitaly Martynenko 

Thanks for the reply, this is the validation I used


but, only joinDate condition show the error message. 

DateOfIncident condition doesn't appear an error


Solution

Hi Ayu, 

In order to keep your flow as it is, change the condition in date of incident validation to:

DiffDays(exForm.Record.Ex.DateIncident, CurrDate()) > 90 or DiffDays(exForm.Record.Ex.DateIncident, CurrDate()) < 0 

Than it will show the error..

Cheers.

EDIT: Or as @Kilian bring to my attention, the second condition doesn't need to be a DiffDays:

DiffDays(exForm.Record.Ex.DateIncident, CurrDate()) > 90 or exForm.Record.Ex.DateIncident < CurrDate() 

Solution

Ayu Andini wrote:

You need to change this to be DiffDays() < 0 or DiffDays() >= 90.

And probably you would want to change error message to not mention 3 month but 90 days.