Date field error in task form - when default is value pre-filled via calculation

Hi all,
I have a task form whose values are pre-filled using values from a previous form.
The pre-filling works well except for fields of type date.
Any reason why this is happening?

The image above was taken today May 23 2023, and the dates are pre-filled by the task so no date is in the future contrary to what the message says. I removed the constraint from the dates and got an “invalid value” error.

Bellow is a screen shot of the xlsform

Any help will be most appreciated.
Thanks in advance

Hello @nsaibirni and welcome to the CHT Forums! I have a few follow-up questions to help us understand a little more about your situation:

  • Which version of the CHT are you running?
  • Can you still submit the form (via the “Suivant” button)? (This will help to determine if the underlying form logic still considers the constraint to be violated or if the display is just not properly updated…)
  • If you chose a different valid value for the date does the constraint error go away? What if you go back and select 2023-05-10 again?

Hi @jkuester,
Thank you for getting back and I am happy to join the CHT Forum.
Below are the responses:

  • CHT Version: 3.13.0
  • No when the submit button triggers the constraint error and stays on the same page.
  • I have tried to choose a different value but the error persists.

Got it, thanks! This information seems to be pointing to some unexpected form logic. The system still thinks the values are invalid for some reason. What could be causing this is not clear from the screenshot of your xlsx file.

Can you possibly provide a link to this xlsx file (or a similar example that presents the same issue)? I would like to try to re-create this and debug into what is going on…

Hi @jkuester,
Sure, here’s a link to the xlsx: LINK

This seems to be happening for all date fields in the form.

Thank you for your help.

Oh wow, that is a big form! Okay, so I think to reasonably be able to re-create the behavior, I need one more set of data. Can you do the following?

  • Open the form in a browser and fill it out to the point that you see the error on the page
  • Open the DevTools in the browser (ctrl+shift+i) and open the “Console” tab
  • In the input box at the bottom of the console, run console.log(window.CHTCore.debugFormModel())
  • Post the xml data that is printed to the console

Disclaimer: Make sure that you DO NOT do this in a production environment since this data will contain PHI. Only do this for a test instance.

This seems to be happening for all date fields in the form.

The plot thickens. If this is happening for all the date fields (presumably the ones with the .<today() constraint) then it seems unlikely that it is some random thing that is off in the form logic. :thinking: Just to double-check, can you run new Date() in the browser console (as described above) and let me know what value it prints out?

Are you able to recreate this same error on other browsers/devices?

Hi jkuester,

Turns out the error was from Safari. I always use Chrome but because I wanted to connect with more than one user at a time, I used Safari :sweat: :man_facepalming:

I got an error on the Safari Dev Tools

TypeError: undefined is not an object (evaluating 'window.CHTCore.debugFormModel')

When I changed to Chrome, dates no longer show an error.
I suppose this is browser-support related?

ps: new Date() works well and returns the current date and time.



When I changed to Chrome, dates no longer show an error.

Great! So glad to hear this!

I suppose this is browser-support related?

Yes, I believe it is. The CHT only supports Chrome and Firefox. My guess is that somewhere in the underlying Bootstrap code that we are using for those date pickers, we are not pulling in the necessary dependencies for Safari (or something of that nature)… FWIW, I often use private windows in Chrome when testing multiple sessions simultaneously!

Thanks for your help @jkuester

1 Like