Selecting Dynamic Variables to use within a workflow

Is it possible to dynamically select within a workflow a Variable to use? What I’m looking to do is:

  1. Pull a list of values from a datatable
  2. Pull a list of names of Variables already created
  3. Using For Each row I want manipulate the Value as required and then assign it to the Variable pulled from the list
    Reason for this I need to manipulate the values but want a single place for the code so it’s easy to manage, as opposed to changing the manipulation on many entries manually.
    Appreciate I might be looking at this wrong and there might be a better way?

Hi @HC-RB

Could you share some input and output data, then we are able to understand your requirement.

I’m extracting individual fields out of a Json. Currently I’m using a lot of Assigns to do this with the same code. For example, I have a variable called NameRoad and I’m assigning this string to fetch the field from the Json:

If(MultiplePageAnalyzeFormResult.AnalyzeResult.Documents(0).Fields(“NameOfRoad”).Content Is Nothing, “N/A”, MultiplePageAnalyzeFormResult.AnalyzeResult.Documents(0).Fields(“NameOfRoad”).Content.ToString.Trim)

That works fine, however I’ve over 100 Variables and so if I need the change the string to assign to them it’s a big task to go through them all.

My thinking was I know the names of the fields in the Json I need to capture, so I can pull that information from a Datatable and use a For Each to go through each Row and amend the string with that fieldname. That way it’s only 1 string is needing to change if required.

What I’m struggling is finding a way to tell the system which Variable to use with each For Each loop to assign the result. I can get the names of the Variables to use, but drawing a blank on how to insert the Variable name with each loop.

I might be looking at this whole problem wrong so happy to listen to other ideas!

Okay @HC-RB

Instead of using multiple variables create a dictionary variable. Then use the 100 keys then store these keys also in the same excel file. Iterate through each row in excel file in the assign activity at the left side give the key and right side assign the value to the key.

Inside for each it’s not possible to change the variables we cannot make it dynamic instead of that use this dictionary approach.

Where you are using these variable use the dictionary variable with key to get the value in it.

Hope you understand!!

1 Like

maybe better to set the dynamics earlier and get driven by the JSON Properties / Extraction config, used for a loop

1 Like

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