Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

316
Views
How do I make a node-red node that is already on a flow obey the default values of a newly-added property?

Initially, this is my node configurations.

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
  },
}

This helloworld node is then placed on a flow.

Then, I added another property, secondProp to the configuration and restart node-red.

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
    secondProp: {value: true}
  },
}

When I export the flow, I notice the secondProp is set to false. I had expected it to be set to the default which is true

[
{
    "id": "04abe6r5baqs16dc",
    ...
    "firstProp": false,
    "secondProp": false, //expected it to be true
    "x": 290,
    "y": 360
}
]

May I know how do I resolve this and ensure the existing custom nodes on the flow obey the default values of a newly-added property?

NOTE:

When I pull the custom node and place it on the flow, it doesn't have this issue i.e., the secondProp value is true.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One of the node-red maintainer commented

The flow file is not modified just because you modified the custom node src. You would have to handle any in-place upgrades in oneditprepare. This is normal behaviour as far as I can see.

So as a workaround, we can only do like this

RED.nodes.registerType('HelloWorld', {
  category: 'HelloWorld',
  defaults: {
    firstProp: {value: false}
  },
  oneditprepare: {
    if (this.secondProp === undefined) {
      this.secondProp = true;
    }
  }
}

Note that this will require us to open the edit dialog of the node for it to take effect.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!