Hi,
I have a workflow, where I want to build a dropdown with some dates based on the submission of the form trigger node. I also would like to add a condition based on the selected radio button in the form trigger node. I created JSON code node as in the attached file. I have a problem, however, to build the next form properly (“Add dates” node in the attached workflow). I want it to display two fields: the dropdown labelled “form fields” and the text input labelled “NIP”. Unfortunately, either it displays only one field (as in the attached workflow) or, after some modifications, it throws an error “not valid json”. Does anybody have an idea how to build this node to achieve my goal?
1 Like
Hi Michal,
The issue is likely how your Code node outputs the JSON. The Form node expects a JSON array at the top level of the output — not nested inside an object or wrapped in a string.
Here’s a working structure for your “Add dates” Form node (set to “Define form using JSON”):
[
{
"fieldLabel": "Select Date",
"fieldType": "dropdown",
"fieldOptions": {
"values": [
{ "option": "your_dynamic_date_1" },
{ "option": "your_dynamic_date_2" }
]
},
"requiredField": true
},
{
"fieldLabel": "NIP",
"fieldType": "text",
"placeholder": "Enter NIP",
"requiredField": true
}
]
Common pitfalls that cause “not valid json” or only one field showing:
-
Wrapping in an object — Don’t return { "fields": [...] }. The Form node expects the array directly. Return just the array.
-
Returning as a string — If your Code node does JSON.stringify(), the Form node receives a string instead of a parsed object. Return the array as an actual object.
-
Multiple items instead of one — Your Code node should return one item containing the full array. Use this pattern in your Code node:
const fields = [
{
fieldLabel: "Select Date",
fieldType: "dropdown",
fieldOptions: {
values: dates.map(d => ({ option: d }))
},
requiredField: true
},
{
fieldLabel: "NIP",
fieldType: "text",
placeholder: "Enter NIP",
requiredField: true
}
];
return [{ json: fields }];
The return [{ json: fields }] is the key part — single item, array goes into json. This is what most people miss.
For the radio button condition — use an IF node after the Form Trigger to branch, and connect the correct branch to the “Add dates” Form node. Each branch can have its own Form node with different field definitions.
Hope this helps!
1 Like
Hi,
Your solution worked for me perfectly. Thank you!
1 Like
Hi,
Your explanation is thorough and valuable. I will bear your recommendation in mind - they will be helpful also in my future workflows. Thank you!