How to use variable in condition

I have a process that refers to a specific excel column header in several places. I’d like to be able to manually change the column being referenced using a variable.

For example, “Column A” is used three times throughout my process. By replacing “Column A” with {active_column} variable I can perform the process on Column A, Column B, etc. by changing the variable.

I created the variable and given it top-level scope. I have tried using the “Use variable” option in the Expression editor but it inserts the variable as plain text. I have tried using curly brackets.

A couple of examples of what I need help rewriting:

String.IsNullOrEmpty(CurrentRow.ByField(“{active_column}”))

CurrentRow(“{active_column}”)

Hi!
String.IsNullOrEmpty(CurrentRow.ByField(active_column))

CurrentRow(active_column)

Is the way to go!
Remember it has to be a string type variable.

@riley,

If you expect any null values in the column use this one

String.IsNullOrEmpty(CurrentRow(active_column).ToString())

If not going to get any null values use this one

CurrentRow(active_column).ToString()

So weird, I tried that and got “Column active_column does not exist” (or similar)…

But of course now I try it and it works :slight_smile: must’ve been a typo.

Thank you!

1 Like

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