0

I have an infopath form with 4 buttons, each button corresponds to a different view. When the form loads, only first 2 buttons are visible and when users fills in the fields in the first two buttons(views) submits the forms. When the same form is open, now the last two buttons become visible. Now the problem is that i have a required date field in the 3rd view, so when i try to submit the form for the first time(i.e filling only the fields in 1st and 2nd view), i get an error saying that the date field(which is in the 3rd view) "only dates allowed".

any suggestions?

3 Answers 3

1

Another option would be to set it as an optional field so it isn't required on submit and on edit, use rules to make it a required field (and disable and submit buttons until a value is supplied).

1

I've been banging my head on some walls lately with just that issue. Date fields and InfoPath don't seem to always play nice.

To help with troublshooting, you may want to create a calculated field and set it to the value of the problem date field. When previewing the form, you will see a text in the format

yyyy-MM-ddTHH:mm:ss

If that calculated field's text is missing some of these aspects, the field will not be accepted as a date field.

I have experienced that entering "1/1/2013" manually in the date field may (or may not!!) render an invalid date, but selecting the same date from the date picker works just fine. I have so far not found what magic is required for a manually entered date to work, or what differentiates a manually entered date from a date picked with the date picker.

You can try formulas to ensure that the date field is getting the entry it requires, for example with ...

concat(substring-before(TheField,"T"),"T","00:00:00")

... but this only seems to work sporadically in my environment.

Picking the date from the date picker seems to work best.

0

I had a similar requirement to populate a date field with the last date of the current month. I ran into the same issue with respect to getting the date picker to accept the date value I was placing into the default value. I ended up using the following piece of code to create a date time string that would be accepted by the date control as a valid date field:

concat(substring(addDays(concat((number(substring(now(), 6, 2)) + 1), "/01/", number(substring(now(), 1, 4))), -1), 1, 4), "-", substring(addDays(concat((number(substring(now(), 6, 2)) + 1), "/01/", number(substring(now(), 1, 4))), -1), 6, 2), "-", substring(addDays(concat((number(substring(now(), 6, 2)) + 1), "/01/", number(substring(now(), 1, 4))), -1), 9, 2), "T09:01:01")

This code will have issues on the last day of the year, but should work well on other days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.