Passing a list of strings in a flow variable

Hi,

I am trying to populate the possible choices in the Multiple Selections node from the Quickform category dynamically. For that, I want to pass a dynamically created vector/list of strings as a flow variable to this node. But I found out that I cannot pass a vector/list as a single flow variable.
Need help with this!

Hi @nehaj, welcome to the forum.

What have you tried so far? It’s most helpful if you provide more context for your problem, including a workflow that we can open, sample data, and an idea of your desired output.

I have no problems creating a variable from a list of strings and using it to populate the list of choices in a Multiple Selections configuration node. Note that quickform nodes have been deprecated in KNIME. 4.0 and newer.

2 Likes

Knime_Question_FlowVar (1).knwf (19.5 KB)

Hi @elsamuel,

Thanks for your reply. I have attached the workflow and the datafile here.
Inside the component, there is a Multiple Selections widget node, to which I want to pass a list of strings. I tried doing this by concatenating the strings but it shows a single option (the concatenation string) in the twinlist.

KnimeQuestion_demodata.xls (18.5 KB)

Hello @nehaj,

but pass which list of strings? What is your use case cause have a feeling maybe a different approach/node could be used?

Welcome to KNIME Community!

Br,
Ivan

This is why you should always provide more context and the actual workflow from the beginning. The vocabulary you used implied one thing, but your workflow says something else entirely.

From what I can tell, you tried used the Table to R node to concatenate the cluster names. As far as KNIME is concerned, the result is a string, not a list of strings.

If you compare the icons for string variables
image )
and list variables
image
you’ll see that they’re completely different. This should give you a clue that this node is not accomplishing what you think it is accomplishing.

I don’t understand the role of the Nominal Row Filter node.

I agree with @ipazin that a different approach is warranted.

Without knowing more about what you’re trying to accomplish, the approach I would personally take, is to use a Duplicate Row Filter node to remove duplicate cluster names, then a Transpose node to convert the Cluster column to a row, then a Create Collection Column node to create the list of cluster names. At that point the list can be converted to a flow variable using a Table Row to Variable node and used in whatever widget you like:

8 Likes

This is what I was looking for. Thanks a ton @elsamuel.

Got your point, will try to explain better the next time.

1 Like

I tried replicating the solution and got stuck at the last step: Table Row to Variable node.

PassVectorAsFlowVar (1).knwf (33.8 KB)

If I check the output of the Column Filter node, it contains single column - AggregatedValues and the first row contains the list of values. Now, as per the explanation given for Table Row to Variable node, it should convert all the column names to variables with their values as the first row under each of these columns. But the output of this particular node gives a single variable called RowID with the value assigned to it as Cluster.

Due to this, I am still not able to populate the cluster values in the Multiple Selection Widget node. Is there something that I am missing in the configuration of any of these nodes here?
KnimeQuestion_demodata.xls (18.5 KB)

Hello @nehaj,

your collection/list is of type Non-native and thus can not be converted to flow variable of collection type. Use Column Auto Type Cast node after transpose node.

Br,
Ivan

2 Likes

Thanks @ipazin. It worked! :smiley:

1 Like

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