cancel
Showing results for 
Search instead for 
Did you mean: 
daniel_will
Nintex Newbie

Having fun with Date / Time in Nintex Forms

Jump to solution

Hi fellow Nintex Admins,

I have a form with a star and end date/time for a meeting:

and I want some validations and automation, when the user fills out the form.

What works is that I check if the start date is in the past and that the end date is not before the start date.

For the end date I use:

{Selbst} < Sitzungsstart

and for the start date:

{Selbst}< Aktuelles Datum

What was really interesting for me, the validation for the end date also checks for the time not only the date, what is great.

So I wanted to achieve this also for the start date with:

If({Selbst}< Aktuelles Datum || {Selbst} <Aktuelle Zeit)

Any ideas why this doesn't work?

The second problem is that I want to set the end date = the start date, when the user sets the start date, cause most meetings end on the same day. How can I do that?

The third question is, if there is a way to check if a validation is needed, depending on another validation. At the moment I have two validations on the end date field:

The first check if it is null or empty:

and the second if the date/time is before the start date:

If the user does not choose a date, both messages pop up. I would like, that the second validation only fires, when the field is not empty.

Thank you for your help

Daniel

Labels: (3)
Tags (1)
Reply
6 Replies
emha
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

So I wanted to achieve this also for the start date with:

If({Selbst}< Aktuelles Datum || {Selbst} <Aktuelle Zeit)

Any ideas why this doesn't work?

I guess your "Aktuelles Datum" is common property "Current Date", "Aktuelle Zeit" is "Current time", "Selbst" is "Self"

Current time is just time without date, and Self returns whole date time so you compare different things.

I think you are not able to compare it with these properties.

I would do it so that I would place another date-time control on the form and set its default value to 'today' and then compare start date against value of this control.

however, note that 'today' rounds up to the next full hour. if you would like exact hour&minute values you would need to set it  by javascript in a similar way as I will show bellow.

The second problem is that I want to set the end date = the start date, when the user sets the start date, cause most meetings end on the same day. How can I do that?

you will have to do it by javascript.

the script might look like this.

NWF.FormFiller.Events.RegisterAfterReady(function () { 

       NWF$("#"+StartDateVar).change(function () {   //sets the date box

             NWF$("#"+EndDateVar).val(NWF$("#"+StartDateVar).val());           

        })

       

       NWF$("#"+StartDateVar).parent().find("select[id*='DateHours']").change(function () {   //sets the hour box

             NWF$("#"+EndDateVar).parent().find("select[id*='DateHours']").val(NWF$("#"+StartDateVar).parent().find("select[id*='DateHours']").val());           

        })

       

       NWF$("#"+StartDateVar).parent().find("select[id*='DateMinutes']").change(function () {   //sets the minutes box

             NWF$("#"+EndDateVar).parent().find("select[id*='DateMinutes']").val(NWF$("#"+StartDateVar).parent().find("select[id*='DateMinutes']").val());            

        })

})

The third question is, if there is a way to check if a validation is needed, depending on another validation. At the moment I have two validations on the end date field:

you can not setup dependencies between single condition, but you can build more complex conditions using logical AND, OR, NOT...

so may create a condition like:   istNullOderLeer(Selbst) && Selbst < SitzungsStart

or using runtime functions:  and(istNullOderLeer(Selbst), Selbst < SitzungsStart)

Reply
daniel_will
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

Thank you very much for your answer, but i still need a little help, cause i never worked with Forms before.

So i though i would just add this script to the custom javascript of the form and activate /name the date/time fields that way:

I also created to form variables:

But nothing happend :/

0 Kudos
Reply
emha
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

yes, copying script and setting javascript variables for datetime picker control should be enough.

you do not need any form level variables.

open developer console and check whether you don't get any errors.

sometimes copying directly from browser may break the script.

maybe I would as well checked how your elements are labeled in HTML structure (I mean 'DateHours' and 'DateMinutes'). since all your environment seems to be in german, they as well might have got translated.

0 Kudos
Reply
daniel_will
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

Thank you, it was the  missing ";" at the "RegisterAfterReady"

Edit:

I have the date in a repeating section ist there a way that this works vor every line?

0 Kudos
Reply
emha
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

sure, it is.

you just need to identify which row you are currently reading source control value from and copy the value to the target control within the same row.

have a look here how to identify current row and how to read values out of controls within that row Current row in repeating section nintex forms

0 Kudos
Reply
ghkrause
Nintex Newbie

Re: Having fun with Date / Time in Nintex Forms

Jump to solution

Maybe it helps to know that you can add a date/time variable to your workflow which you default to now which is date + hour + minute or you compare with field "Created" which is accurate enough.

Of course, using InfoPath forms or Constraints in SharePoint columns is another way to avoid that a bad entry is submitted at all.

0 Kudos
Reply