I need to merge list of values with one value

Hi,

I am creating a workflow, which access a google sheet and get some records, (let’s say 5). Now I want to find out the number of records, so I created a code node and Edit Field to set “recordCount”. Now in another flow, it pass through each of the records to process data, using a loop over item. Inside the loop I need to access the recordCount. But there is no way I can merge these two as there are no matching records. Is there anyway I can access the record count?

My basic question is, can I set a variable at some point and access it some where else, but not connecting to that node where I set the variable. If not, how can I merge just a variable with multiple records when I don’t have a matching field.

Thank You.

Hey @NadeeraJ hope all is well. It feels like you might be over-engineering something (you don’t need a code node to count elements, you also likely don’t need to set a variable for that count), feel free to share the whole thing if you need help.

To answer you direct question - you can access the variable set in a node which isn’t directly connected to the one where you are trying to access it from.

To do that you can use the following expression:

{{ $('Get row(s) in sheet').all().length }}

This way you can get the number of items returned by a node by its name.

2 Likes

Hi @jabbson Thank you very much for your reply. Like you said I was overdoing it. The solution you mentioned worked well. Thank you.

1 Like

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