Combining strings (Referencing csv and picking a specific value based on a global value)

I'm trying to put a string together to send to google sheets as a msg.cell.
I've got return from google sheets working and I can use a inject node to pick and choose cells to get.
I'm trying to automate it now and I've got two values: msg.currentitem and msg.plusthree
I want to take those two values and combine them like this Sheet1!A(msg.currentitem):E(msg.plusthree)

I tried the string node and appending it but getting a undefined error in my debug node for the section where I'm referencing the msg items. Also tried a basic function and it gives me the same error. Also at the moment the string node gets triggered twice giving me the following output:

8/3/2021, 6:59:26 PMnode: 1710a041f88e2705msg.cells : string[25]


8/3/2021, 6:59:26 PMnode: 1710a041f88e2705msg.cells : string[18]


Any other nodes I can try to stitch it together into one command?
Thanks in advance for any advice

Maybe the template node ?

How would I use two different incoming msg payloads then as part of the formatting? Tried: BTC!A{{msg.currentitem}}:E{{msg.plusthree}}
But it prints it without the messages. Also it still activates twice cause the two values are calculated separately.

I think a function might be a better node to use. I just have no experience with using it or the syntax. The idea is gets a number read in from a csv. Then it needs to stitch the following together:
BTC!A(csv number):E(csv number + 3)

Here's my current flow. The section bottom left is what I'm trying to replace with a function now

Messages will never arrive from 2 places into the same node at the same time. Never.

So you need to either store values in context (then retrieve them) or use something like the join node.

See this article in the cookbook for an example of how to join messages into one object.

1 Like

If I can figure out how to do the function node I won't have two messages to join together. Just using nodes to do basic math and then combining it again at the moment.

Then don't branch flows as that creates multiple messages. Wire in nodes series and store the values in different part of msg so as not to overwrite previous values.

Lastly, see the node-red docs regarding writing functions and using context.


I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour.

There a few gems in that playlist :point_up: that will help it all just "click" for you. for example, the copy path button on the debug output.

Refactored most of my flows now based off that playlist. Also changed things around to now periodically update from the google sheets but also store a local csv. The thing I'm struggling with now is referencing a certain value from the csv as it's a big array(?) of data. Basically I want to go and reference a certain col and then a amount that I've set to a global value but not having any luck with change nodes and understanding how I'm going to filter it.

1 Like

The last one is where I'm stuck now. Basically just need to get a value from col 4 and a row that's referenced by a global value.
I've put all of my tcp connections on a separate flow to prevent them from constantly reconnecting whenever I deploy changes.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.