How to get Function's msg within a Template script?

Greetings! I am very new to Node-Red and have been having a very difficult time finding a solution that makes sense to me, with my limited understanding of the process of things. Hopefully someone can help with this issue I'm having...

I have an app using FormIO to build a form. The data for which fields to build exists in a Function node - called form_definition - I have a Function node which is basically

msg.payload = { "array":["of", "objects"] }
return msg

In a Template node I have my HTML and in a <script> tag on the body of the page. I need to do the following in order:

  1. Load external data (which works)
  2. Using the data, create a new Object var which contains some - but not all - of the msg.payload keys and values. Which ones get filtered out, changed, or remain is determined by the data loaded in step 1
  3. Pass the filtered msg.payload clone into FormIO to create a form - which fields are created will be determined by which fields were and weren't removed or edited from the original form_definition

(for example: the form_definition has a required Password field. But, there may be a case where a password field isn't required, and so I don't want FormIO to concern itself with that info when it renders the form)

The only way I can find to even look at msg.payload is via "{{{payload}}}" but that just returns me [object Object] as a String, not an actual object. I'm unsure how to get a workable JSON String or Object returned to me in this step.

Should I try another type of node? JSON, a Switch? Should something get renamed? Does my body <script> tag need to get moved to an external Functional node?

Any help would be appreciated , thank you!

It would be helpful if you provide and export of th function and template nodes so we can see what you actually have.

Also, attach a debug node (set to display the complete msg object) to the outpt of the function node and copy it's contents and paste them to a reply. Having the actually cde and data saves time for people that are willing to help you.

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.


How is this different from Get msg.payload from Template's script tag?

As they seem to be the same, I will close this thread. If they are in fact different, you can reopen the thread and explain the difference.