# Pre-fill an edit form node

**URL:** https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393
**Category:** Dashboard
**Created:** [3 September 2020 10:34 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393 "2020-09-03T10:34:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [3 September 2020 10:34 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/1 "2020-09-03T10:34:00Z")

</div>

Good morning all,  
I am trying to pre-fill an edit form node from the payload of an inject node (+ an edit file node) configured to retrieve the data in a file and send it to the edit form node when node-red starts.  
After many attempts, I cannot see the payload I injected in the form. Could someone tell me if this is possible or if there is any chance that I will end up in this path?  
Thank you in advance.

```auto
[{"id":"59419fa0.6d681","type":"inject","z":"48a44363.6db4fc","name":"","topic":"","payload":"test","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["bedd3777.e51e98"]]},{"id":"c64528c3.9d1808","type":"link in","z":"48a44363.6db4fc","name":"question secrete","links":["ae527b20.44f4f8"],"x":100,"y":160,"wires":[["bedd3777.e51e98","a7115b5c.39e998"]],"l":true},{"id":"bedd3777.e51e98","type":"ui_form","z":"48a44363.6db4fc","name":"Q1","label":"","group":"6dd826fe.c1c108","order":2,"width":0,"height":0,"options":[{"label":"Question secrète","value":"question","type":"text","required":true,"rows":null}],"formValue":{"question":""},"payload":"","submit":"Confirmer","cancel":"Annuler","topic":"","x":253,"y":160,"wires":[["1db6023d.08acde","2e8815a1.216dba"]]},{"id":"a7115b5c.39e998","type":"debug","z":"48a44363.6db4fc","name":"q1 test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":370,"y":60,"wires":[]},{"id":"6dd826fe.c1c108","type":"ui_group","z":"","name":"Définissez la question secrète et sa réponse qui vous permettront de rééditer votre code PIN en cas d'oubli","tab":"8808e7b4.9fd008","order":3,"disp":true,"width":"6","collapse":false},{"id":"8808e7b4.9fd008","type":"ui_tab","z":"","name":"VOTRE PROFIL","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [3 September 2020 10:50 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/2 "2020-09-03T10:50:17Z")

</div>

did you try a search of the forum??? try searching for `ui_form`

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [3 September 2020 10:55 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/3 "2020-09-03T10:55:25Z")

</div>

Yes I tried by searching for "edit form node". 150 results and no solution. I'm currently trying to put {{global.first\_question}} in "Name" inside the form.

I will try immediately "UI\_form"

Thanks for your response

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [3 September 2020 12:34 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/4 "2020-09-03T12:34:59Z")

</div>

Well done for your UI\_form search tip. Indeed with the post "How to initialize the user interface of the form" I created a function node which does the job with:  
msg.payload = {"question": "test"}  
return msg;

On the other hand, if I replace the word "test" by a context data, it does not work.  
Example:  
msg.payload = {"question": {{global.first\_question}}}  
return msg;  
Many thanks for your help and if you have an idea to inject a context data ...  
Thanks again,  
Laurent

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [3 September 2020 12:43 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/5 "2020-09-03T12:43:34Z")

</div>

In a function you need to `get` the global. Take a read of [https://nodered.org/docs/user-guide/writing-functions#getset-multiple-values](https://nodered.org/docs/user-guide/writing-functions#getset-multiple-values)

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [3 September 2020 14:05 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/6 "2020-09-03T14:05:49Z")

</div>

Thank you for your advice.  
By getting the data at the exit of a node activated when restarting node-red, I solved the problem with the following solution in the function node:  
input = msg.payload  
msg.payload = {"question": input}  
return msg;  
Thanks again,  
Laurent

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [17 September 2020 14:05 UTC](https://discourse.nodered.org/t/pre-fill-an-edit-form-node/32393/7 "2020-09-17T14:05:50Z")

</div>

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