Pre-fill an edit form node

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.

[{"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}]

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

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

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

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

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

1 Like

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