Dynamic drop down nodes and date format

Hi everyone, i wish that you are fine.
i want to shear with you a flow it' about dynamic dropdown and linked drop down
just i have some issue it's about date format it give me the total format picture 2 and i want the simple format picture 1 .
have a nice day
1

[{"id":"89aa4a33.4c3098","type":"tab","label":"Flow 11","disabled":false,"info":""},{"id":"5e90fb79.aae3d4","type":"function","z":"89aa4a33.4c3098","name":"send data","func":"var inf1 = flow.get(\"inf1\") || 0; \n \nswitch (msg.payload){\n\n    case \"name1\":\n      inf1 = msg.payload; \n    flow.set(\"inf1\", inf1);\n      msg.options = [\"A\", \"B\",\"C\",\"D\"] ;break\n      return;  \n        \n    case \"name2\":\n    inf1 = msg.payload; \n    flow.set(\"inf1\", inf1);\n     msg.options = [\"A1\", \"A2\",\"A3\",\"A4\"] ;break\n        return;\n        \n     }\n//msg.payload = \" type darret \"+ inf1 +\" , type de probleme \" + inf1;\n\n//msg.topic = \"go\";\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":501,"y":169,"wires":[["32349dc8.c1ff32","2b65cf2c.f2d1b"]]},{"id":"8f5e1797.f1f9c8","type":"ui_dropdown","z":"89aa4a33.4c3098","name":"1","label":"1","tooltip":"","place":"Select option","group":"f4ddc713.cb9a58","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"name1","value":"name1","type":"str"},{"label":"name2","value":"name2","type":"str"}],"payload":"","topic":"","topicType":"str","x":365,"y":168,"wires":[["5e90fb79.aae3d4","80f6a087.697cc"]]},{"id":"32349dc8.c1ff32","type":"debug","z":"89aa4a33.4c3098","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":532,"y":105,"wires":[]},{"id":"2b65cf2c.f2d1b","type":"ui_dropdown","z":"89aa4a33.4c3098","name":"2","label":"2","tooltip":"","place":"Select option","group":"f4ddc713.cb9a58","order":3,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","topicType":"str","x":677,"y":168,"wires":[["e8e637e3.85ed18","77d13440.0b5dac"]]},{"id":"e8e637e3.85ed18","type":"debug","z":"89aa4a33.4c3098","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":722,"y":105,"wires":[]},{"id":"80f6a087.697cc","type":"debug","z":"89aa4a33.4c3098","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":344,"y":105,"wires":[]},{"id":"77d13440.0b5dac","type":"function","z":"89aa4a33.4c3098","name":"send data2","func":"var inf2 = flow.get(\"inf2\") || 0; \n \nswitch (msg.payload){\n\n    case \"A\":\n      inf2 = msg.payload; \n    flow.set(\"inf2\", inf2);\n      msg.options = [\"Aa\", \"Bb\",\"Cc\",\"Dd\"] ;break\n      return;  \n       \n        \n    case \"A1\":\n        inf2 = msg.payload; \n  flow.set(\"inf2\", inf2);\n     msg.options = [\"b11\", \"b22\",\"b33\",\"b44\"] ;break\n        return;\n        \n     }\n//msg.payload = \" type darret \"+ inf1 +\" , type de probleme \" + inf2;\n\n//msg.topic = \"go\";\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":843,"y":167,"wires":[["10f09aa.ce6cb65","a239eaaa.99d148"]]},{"id":"a239eaaa.99d148","type":"ui_dropdown","z":"89aa4a33.4c3098","name":"3","label":"3","tooltip":"","place":"Select option","group":"f4ddc713.cb9a58","order":4,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","topicType":"str","x":1037,"y":168,"wires":[["56180deb.0766d4","db206626.a18878"]]},{"id":"10f09aa.ce6cb65","type":"debug","z":"89aa4a33.4c3098","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":105,"wires":[]},{"id":"56180deb.0766d4","type":"debug","z":"89aa4a33.4c3098","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":105,"wires":[]},{"id":"9e065b92.84e238","type":"ui_text","z":"89aa4a33.4c3098","group":"f4ddc713.cb9a58","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"col-center","x":1352,"y":168,"wires":[]},{"id":"db206626.a18878","type":"function","z":"89aa4a33.4c3098","name":"take the  data","func":" var a = flow.get(\"inf1\");\n var b = flow.get(\"inf2\");\n if (msg.payload !== undefined || msg.payload.trim() !== \"\")\n\n\n    //msg.payload =  data1  + data2 + msg.payload;\n    msg.payload = \"type d'arret :   \" + a +\"   \"+ \"type de probleme :   \" +  b +\"   \" + \"spécification :   \" +  msg.payload +\"   \" + new Date();\t\n \n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1204,"y":168,"wires":[["9e065b92.84e238"]]},{"id":"802a778a.98a6b8","type":"ui_button","z":"89aa4a33.4c3098","name":"","group":"f4ddc713.cb9a58","order":5,"width":6,"height":1,"passthru":true,"label":"Clear","tooltip":"","color":"","bgcolor":"","icon":"close","payload":"' '","payloadType":"str","topic":"","topicType":"str","x":50,"y":168,"wires":[["7f828c49.91ddf4"]]},{"id":"7f828c49.91ddf4","type":"change","z":"89aa4a33.4c3098","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":206,"y":168,"wires":[["8f5e1797.f1f9c8","2b65cf2c.f2d1b","a239eaaa.99d148","9e065b92.84e238"]]},{"id":"f4ddc713.cb9a58","type":"ui_group","name":"form","tab":"5185e0f4.4741d","order":1,"disp":true,"width":"15","collapse":false},{"id":"5185e0f4.4741d","type":"ui_tab","name":"Form","icon":"Form1","order":2,"disabled":false,"hidden":false}]```

Hi, please dont mass tag members. We will see (and respond) if we can help, when we get a moment.

Speaking of which, you can use $moment in JSONata

See here: Formatting times & dates with moment.js examples

2 Likes

Ok, sorry if it something wrong
about the format date i want it to use it in function node

Have you done a google search? Try ‘JavaScript date formatting’

Do you realize you send a msg to the text node three different ways in your flow??

1 Like

Why? Just pass your message through a change node to append a formatted date...

JSONata: payload & " " & $moment().format("YYYY-MM-DD HH:mm")

image

[{"id":"db206626.a18878","type":"function","z":"89aa4a33.4c3098","name":"take the  data","func":" var a = flow.get(\"inf1\");\n var b = flow.get(\"inf2\");\n if (msg.payload !== undefined || msg.payload.trim() !== \"\")\n\n\n    //msg.payload =  data1  + data2 + msg.payload;\n    msg.payload = \"type d'arret :   \" + a +\"   \"+ \"type de probleme :   \" +  b +\"   \" + \"spécification :   \" +  msg.payload;\t\n \n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1204,"y":168,"wires":[["dfea603.94268a"]]},{"id":"dfea603.94268a","type":"change","z":"89aa4a33.4c3098","name":"Append nice DateTime to msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & \"   \" & $moment().format(\"YYYY-MM-DD HH:mm\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":300,"wires":[["9e065b92.84e238"]]},{"id":"9e065b92.84e238","type":"ui_text","z":"89aa4a33.4c3098","group":"f4ddc713.cb9a58","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"col-center","x":1410,"y":300,"wires":[]},{"id":"f4ddc713.cb9a58","type":"ui_group","name":"form","tab":"5185e0f4.4741d","order":1,"disp":true,"width":"15","collapse":false},{"id":"5185e0f4.4741d","type":"ui_tab","name":"Form","icon":"Form1","order":2,"disabled":false,"hidden":false}]
1 Like

thank you so much Mr Steve for your time
have a nice day .

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