I want to create a list inside a loop with the name changing for each iteration, is that possible?
You create a variable with datatype list then use the Add to Collection activity to add items to the list.
Name of what changing? Name of the variable? You can’t do that.
hi @postwick ,
If i create a variable with datatype list, i will be hard coding my code, I do not know how many variables I need to create since the source will be updating.
can you give an example on what do you need please,
be more efficient in the questions, so we can help better
regards!
Hi @fernando_zuluaga ,
I apologize for my ambiguous question,
I have a for loop and there is an if condition
if the condition is met I have to create a new list and store the value in it
if the condition is not met I have to create a different list and store the value in it.
Is it possible to automate creating the list?
Thank you.
so you need 2 list, one for the then and another for else process?
or you need to create any number of lists?
I need to create any number of lists, based on the condition
we can’t create variables in the workflow, just from the variable panel or using the ctl + k hotkey and setting the name of it. For your purpose you need to create those variables before running the workflow and then overwrite it, for add an element in your list you can do it like that
but, i think that you need to change some of your automation, i don’t think that your purpose will be reliable for your automation, considering that it is in a if condition, you can add those values in two differents collections
hope it helps
@ice_cream If you have multiple lists need to be created based on the multiple conditions then it would be better to go for switch case instead of if. Use the below link for writing a condition for switch case
Also, you can create different lists for each condition you have but those has to be defined in prior.Use the below link
in some cases a dictionary can help:
the key would let identify on which list is refered
the value will be a list on which items can be added
it is dynamic as long the keys are unique
It sounds like you need to use a Dictionary(of string, list)
Then you can do things like…
Assign myDict(“First List Name”) = {“a”,“b”,“c”}
Assign myDict(“Second List Name”) = {“d”,“e”}
etc.
Then you can get a list of all the list names using MyDict.Keys.ToArray and loop through it, for example. And you can use Add to Collection to add to myDict(“First List Name”) or myDict(“Second List Name”) etc.
This makes the name of your lists entirely dynamic. The only actual variable is myDict.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.