Assign variable from Excel variable (tricky!)

This is a tricky one - anyone up4it?:wink:
I have done this by multiple assign, but as the XLS grows I had the idea to take Column-1 (variable) on the left side of the assign and column-2 (default-value) on the right side. All the variables have been properly defined in the workflow already, just want to assign in a for-each row. This would let me add easily new variables (declare in workflow and add to xls) and also re-sort easily.

Old style multiple assign (manually adding line by line):
SAP_username = db_parameter.Rows(0).Item(“default-value”).ToString

new idea assign (for each row):
row.item(“variable”) = row.item(“default-value”).ToString

Any idea how I can convince assign that the variable is built out of a variable?

as far I do understand you are searching for an aproach to create dynamicly variable. A variable has to be defined before compiling and not on runtime.Currently you are creating a variable with the name: “row.item(”“Variable”)…

You can do similiar to the REF Configuration EXCEL with a dictionary Of String, Object. In that case you have to cast e.g. you want a boolean as boolean

Another technique could be to work with a dictionary Of String, Tuple(Of String, String, Boolean, Int32, Double, Object)

so based on your swithc datatype logic you store the value e.g. for Display_Animation like:
dictJobVars(“Display_Animation”) = Tuple(Of String, String, Boolean, Int32, Double, Object)(“B”, , True, , ,)

And can retrieve as Boolean with dictJobVars(“Display_Animation”).Item3


thanks @ppr … I have defined all variables before compiling in the workflow main.xaml. The names match 1:1 with the name in Excel Column-1.
I would just like to reference (not create) the pre-defined variable by the value in excel (C1) and the assign the value (C2). But in a dynamic way…

If I get your suggestions right, I would have to crawl line by line (aka variable by variable)?

Same case. The value on the left side from Assign Activity is not static (so called not known on compiling). Compiler cannot pick up and so it will not wired.

1 Like