Use of a flow variable in an if statement

I want to save a value in a flow once and then compare it to future message payload field in a function block.

I have saved the value I want to compare in a flow named color:

colora = flow.get(“color”)

now I want to compare that value in color it to a field in an if statement

if (msg.payload.id == colora)
{msg.payload.new= “blue”}
else {msg.payload.new=“white”}

my problem is that it never detects when msg.payload.id actually matches the value in the flow.color field so everthing is “white”.

at some point in your flow, did you set a value for the “color” variable?

flow.set("color", "blue");