node-red-contrib-image-tools
node-red-contrib-image-tools copied to clipboard
Unable to get "text" to accept a property as input.
I _think i am trying to do something simple.
I have a mysql-node that returns the following msg.payload
To me, that would mean that I could use the following to access the data
But that just results in"TypeError: text.replace is not a function"
I've tried pretty much any string conversion trick I can think of, and I still cannot get "print" to accept dynamic input data.
What the heck am I missing?
Try changing the type of the text field to jsonata & putting payload[0].day & ''
as the expression.
Alternatively, add a function node before the image node& enter..
msg.payload[0].day = String (msg.payload[0].day)
return msg
Try changing the type of the text field to jsonata & putting
payload[0].day & ''
as the expression.Alternatively, add a function node before the image node& enter..
msg.payload[0].day = String (msg.payload[0].day) return msg
Thank you for responding.
Now, J is not available in the image-node. Just "msg" "flow" or "global". It would be nice to have that as an input type. :)
However, using a function node in front to process the data worked. But I really fail to see what makes that different from the methods i tried. But, this at least works as a workaround. Thank you.
The issue is 7 is a number
in JS, number.replace
is not a function but string.replace
is! (under the hood, your value is sanitised to prevent crashing & remove/convert non ASCII characters using the string.replace
function)
In other words, you need to pass a value of string type (e.g. "7"
not 7
) to the text
item
NOTE FOR SELF...
- consider adding a
.toString
or raise an error stating"Value is not a string"
to better aid users.
The issue is 7 is a
number
in JS,number.replace
is not a function butstring.replace
is!
Groaaan... I know better. I work with this stuff. I'm an engineer dammit.. But, staring at something for too long aparently makes you blind. Yeah, "Value is not a string" probably should snap me out of it sooner . ;)
Hi I am a newbie to Node red and am having problems trying to use a variable in the text field as described here. I want to add such variables as temperature, humidity etc to my saved image. I understand from the above that I need to convert my variable to a string in a function node before the edit image node. I am not clear on the statement to add into the text box. As noted above the options are msg, flow, global. Help please on the way to reference the string created in the function node. Thanks Since writing I think I have worked out the solution. I used flow.set to take my string value and then choose the flow option in the text box.