# Preload Date field in ui\_form

**URL:** <https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416>\
**Category:** General\
**Created:** [7 April 2020 16:02 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416 "2020-04-07T16:02:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 April 2020 16:02 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/1 "2020-04-07T16:02:48Z")

</div>

Can anyone tell me how to preload a Date field in a ui\_form? I have tried `new Date()`, `new Date().getTime()` and `new Date().toISOString()`. I can't think of anything else to try. I am able to preload other field types ok.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e9ec1b25a0dd55bfa700929270b0be8ed0791193.png)

```auto
[{"id":"4e33788d.298f48","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":657,"y":733,"wires":[]},{"id":"f92257e5.9f821","type":"ui_form","z":"bdd7be38.d3b55","name":"Date form","label":"","group":"903a6ab8.4f4ca8","order":1,"width":0,"height":0,"options":[{"label":"Date","value":"date","type":"date","required":true,"rows":null}],"formValue":{"date":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":481,"y":690,"wires":[["4e33788d.298f48"]]},{"id":"241b81f7.4e284e","type":"function","z":"bdd7be38.d3b55","name":"new Date()","func":"msg.payload = {date: new Date()}\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":641,"wires":[["f92257e5.9f821"]]},{"id":"caadbfef.f62a9","type":"inject","z":"bdd7be38.d3b55","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":92,"y":642,"wires":[["241b81f7.4e284e"]]},{"id":"75d480ef.1cc42","type":"function","z":"bdd7be38.d3b55","name":"new Date().getTime()","func":"msg.payload = {date: (new Date()).getTime()}\nreturn msg;","outputs":1,"noerr":0,"x":272,"y":693,"wires":[["f92257e5.9f821"]]},{"id":"b0047d05.6511c8","type":"inject","z":"bdd7be38.d3b55","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":93,"y":692,"wires":[["75d480ef.1cc42"]]},{"id":"a5dfc260.07496","type":"function","z":"bdd7be38.d3b55","name":"new Date().toISOString()","func":"msg.payload = {date: (new Date()).toISOString()}\nreturn msg;","outputs":1,"noerr":0,"x":283,"y":738,"wires":[["f92257e5.9f821"]]},{"id":"3fbcf94.86b2306","type":"inject","z":"bdd7be38.d3b55","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":94,"y":737,"wires":[["a5dfc260.07496"]]},{"id":"903a6ab8.4f4ca8","type":"ui_group","z":"","name":"Home","tab":"e2e6f4f5.56f91","disp":false,"width":"6","collapse":false},{"id":"e2e6f4f5.56f91","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

**[Edit]**

```auto
7 Apr 17:17:35 - [info] Node-RED version: v1.0.4
7 Apr 17:17:35 - [info] Node.js version: v12.16.1
7 Apr 17:17:35 - [info] Linux 5.3.0-46-generic x64 LE
7 Apr 17:17:35 - [info] Loading palette nodes
7 Apr 17:17:36 - [info] Dashboard version 2.19.3 started at /ui

```

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [7 April 2020 16:44 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/2 "2020-04-07T16:44:25Z")

</div>

Hello,  
What format does the node put out if you enter a date from the dashboard?  
Sending messages in the same format as the output has worked for me using the form node in other input formats.  
Johannes

Edit doesn’t work 🙁

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 April 2020 16:59 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/3 "2020-04-07T16:59:14Z")

</div>

> [@JGKK](#):
>
> What format does the node put out if you enter a date from the dashboard

It appears to be iso string,

```auto
{"date":"2020-04-06T23:00:00.000Z"}

```

I have tried feeding exactly the above in an inject set to JSON and that doesn't work either.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 April 2020 22:25 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/4 "2020-04-07T22:25:18Z")

</div>

yeah - ok - that's a bug... fix pushed to master branch if you want to try it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 April 2020 09:27 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/5 "2020-04-08T09:27:21Z")

</div>

I installed using  
`npm install node-red/node-red-dashboard`  
and got 2.20.1-beta, restarted node red which confirmed the new version installed, but the test flow I posted still doesn't appear to do anything.  
Edit, I think I should have replied to the previous post so that @dceejay would get notified, I keep forgetting to do that.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [8 April 2020 09:32 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/6 "2020-04-08T09:32:00Z")

</div>

can you try this simple flow to test ?

```auto
[{"id":"5389c329.4deebc","type":"debug","z":"ea593186.4918d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":1140,"wires":[]},{"id":"37564c24.db23f4","type":"ui_form","z":"ea593186.4918d","name":"Date form","label":"","group":"b10fbc0c.f705c","order":1,"width":0,"height":0,"options":[{"label":"Date","value":"date","type":"date","required":true,"rows":null},{"label":"Text","value":"text","type":"text","required":false,"rows":null},{"label":"Switch","value":"switch","type":"switch","required":false,"rows":null}],"formValue":{"date":"","text":"","switch":false},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":680,"y":1140,"wires":[["5389c329.4deebc"]]},{"id":"bb58a406.4c9b98","type":"function","z":"ea593186.4918d","name":"","func":"msg.payload = {\n \"date\":\"2021-02-20\",\n \"text\":msg.payload + \"\",\n \"switch\":true\n \n};\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1140,"wires":[["37564c24.db23f4","a974a3c9.064f7"]]},{"id":"1c4542aa.186c5d","type":"inject","z":"ea593186.4918d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":321,"y":1139,"wires":[["bb58a406.4c9b98"]]},{"id":"b10fbc0c.f705c","type":"ui_group","z":"","name":"Home","tab":"76d6a090.f21d2","disp":false,"width":"6","collapse":false},{"id":"76d6a090.f21d2","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

ensuring you have flushed browser cache first etc etc

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 April 2020 10:10 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/7 "2020-04-08T10:10:43Z")

</div>

In Waterfox the text and switch fields are updating but not the date. Surprisingly, in Chrome, none of them updates.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [8 April 2020 12:09 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/8 "2020-04-08T12:09:59Z")

</div>

are you sure you have flushed the local browser cache - I've found some browsers "stickier" than others for holding onto old code.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 April 2020 13:05 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/9 "2020-04-08T13:05:18Z")

</div>

I am ashamed to say that the problem with Waterfox was indeed the cache and now it works fine, with all the formats from my original sample (new Date(), new Date().getTime() and new Date().toISOString()). What part of Ctrl-F5 doesn't the browser understand I wonder.  
However I still have a problem with Chrome, which is likely a completely different problem. None of the fields update, and in the browser console, immediately after telling it to clear absolutely everything, I see this, which suggests some is still being loaded from the cache, but I am not entirely sure about the meaning of what I am seeing.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/2/72e8b9534ce5f2ff4c5839ae4508822dccd9626f.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [8 April 2020 14:47 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/10 "2020-04-08T14:47:02Z")

</div>

this seems fairly informative - [https://betterstudio.com/blog/clear-browser-cache/](https://betterstudio.com/blog/clear-browser-cache/)

but in your screen shot I would tick the box saying disable cache then ctrl-shift-R a couple of times.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 April 2020 15:25 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/11 "2020-04-08T15:25:09Z")

</div>

I had cleared the cache using the method in the link, and I did it again just to be sure, with all the options in the dialog selected (cookies, history, etc) to no avail. I hadn't noticed the disable checkbox in the developer console and selecting that finally did it. What a pain. All working now, sorry about the hassle. I wish I hadn't tried Chrome now, I only did it in case the issue was Waterfox specific and instead it just wasted everybody's time.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 June 2020 15:25 UTC](https://discourse.nodered.org/t/preload-date-field-in-ui-form/24416/12 "2020-06-07T15:25:09Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
