Flow variable selection at component configuration

Hi,

I have built a component which requires a flow variable (of type Path) as an input.
Currently, this flow variable has to have a certain name (obviously because it is refered to by its name at different places inside the component).

In order to share the component with others, I have to tell everyone that correct name of the flow variable. Of course, it would be much nicer if the user could choose the right variable from his/her list of variables and pass the correct variable name to the component (without ever having to look inside the component itself).

Is there any way to achieve this? I haven’t found any Configuration or Widget node that would allow this…

Hi,
have you tried using variable creator node (string type) and then use String to path variable to convert to type path?
br

Hi @atothep , I have a few components that require a Path variable as part of their configuration.

What I do is this:

Firstly
image

All possible incoming variables are turned into a table row. In the Component Input config you may choose to give them all a prefix so they won’t conflict with anything else that you write in your component.

Once you have the variables turned into “columns”, you can use a Column Selection Configuration that only accepts Paths:

So what this does is turn the variables into “columns” and so the user can select one of those columns using Column Selection Configuration. Yes, they were originally variables, but now a column. But that doesn’t matter because you just want the value!

image

You now you have a variable containing the name of your selected “variable” which is currently a column.

And if you then add a “Variable to Table Row”, and use the flow variable tab configured with the input column set to the variable name that you created in the Column Selection Config, you have a column containing the value of the flow variable they passed in. So now it doesn’t matter what the name of the variable is, because you’ve got the value of it as a column, and you can turn it back into a variable using any name you like!

OK, that may be insufficiently clear. So I have here an example workflow that you can look at

It has an Excel Writer creating a Path flow variable called “testpath”

Within the component, going through the steps listed earlier, I have a table row containing the value of the variable that has been passed in via the configuration

Once I have the value, I can put it into any variable I choose and use it subsequently in the rest of my component

In this demo, the Path variable is selected in the config for the component. Have a play around and if you have any questions please ask. (It may be easier to unlink the component so you can modify things and see how they work.)

Demo of receiving path variable in a component.knwf (52.9 KB)

The component in this example is here

2 Likes

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