Getting all arguments of a workflow in a collection

Hello,

I am looking for a generic way to collect all arguments (in) of a workflow in some type of collection (list would be nice) to display all of their values in a log message. This method should work regardless of the number of arguments, so that I could use it at the begining of each of my workflows. So far, I have been unable to find a method doing this.

Thanks!

2 Likes

Hi buddy @bartierc
In this case we need to mention the DIRECTION of all arguments as IN/OUT
only then we can get the values of each argument that we have defined in each process in the argument panel

  1. After creating the arguments in the argument panel, create a collection list variable in variable panel and name it as out_argument_list of type System.Collections.Generic.List and initiate the variable with a default value like this new list(of string)
  2. And use add to collection activity and mention the list variable name in collection property and the argument name that we have defined all the process with IN/OUT direction, in item property of add to collection and change the type argument as object, as you might have arguments in integer or string or any other type, so lets take it in common with as object
  3. And i would like to tell you that you can display all the values in the list with for each loop activity and passing the list variable as input to the loop and inside using a log message activity to display the values, but we need to make sure that each argument has some default value in it, else only when the arguments gets processed we will be getting the values been displayed in the output panel

Kindly try this and let know buddy and correct me if i have understood the query wrongly
Cheers @bartierc

Thanks for you answer. However, I misunderstand how I can add all the arguments to the collection? I know it should be looped, but I don’t know the loop condition to say “until all arguments have been added to this collection”. I uploaded my workflow so far.

LogAllArgs.zip (13.2 KB)

1 Like

here you go buddy @bartierc
i declared with list variable itself didn;t use add to collectin
kindly have a look at this
Hope its resolved
LogAllArgs.zip (12.5 KB)
Cheers @bartierc

did that work buddy @bartierc

Thanks, but this does not solve my issue. Your solution implies that I know the number of arguments, and add all of them indidually to my list (new list (of object) from {argument1,argument2,argument3}). This means that if i have a worfklow with 20 arguments, with names all very different, it will be a pain to make a list with all of those 20 arguments.

What I’m looking for (if it’s even possible), is a way to make a list of ALL arguments, regardless of how many there are and their names.

Usually we are the one going to create the argument in a workflow, so its very obvious that unless we know there wont be any arguments getting generated…so thats why i tried to mention them explicitly in the list as above which would show you the value at the beginning and i have used in mine as well to know the change of value in all arguments from the beginning to the end …Cheers @bartierc

I’m as usual the late comer. I was thinking if it was possible to load the .xaml file into some kind of an object and then pull the list of arguments as a collection. This is how the Main.xaml file looks like in a text editor.

image

Just thinking out of the box.

UiPath could add an activity for this maybe?

1 Like

Hi Andy, did you manage to find a solution to this? I’m trying to find a way of doing the same thing, reading the arguments in a workflow and assigning them to a collection/dictionary.

I’ve been digging through the .net classes but haven’t found anything useful. With the latest UiPath.System.Activities update, there is an option to log all arguments during an invoke, so there must be a way.

1 Like

Hi Bruce,

I’m yet to pursue this. But think it is possible with the help of this documentation. Did you try this by any chance?

The idea here is to craft the right path to target the x:members section of the xml file as exemplified in this visual below.

image

So that the Main.xaml file is not compromised in some way, I would first make a copy of this file (or have the automation do it) and then read the copy instead of the actual Main.xaml

Thanks

Hello Bruce,

Here is the solution. Please mark it so if it helps solve your problem.

First, the result of my tests.

The Main.xaml file arguments:

And the results extracted using code that I just wrote by reading through MSFT documentation.

Originally my xaml file had only one argument - I subsequently added several more to make sure it works for multiple arguments as well as In and Out arguments.

image

The Details:

There may be other solutions, but I could not read the Main.xaml until I used namespaces to retrieve the information on the x:Members and x:Property nodes. Therefore, as far as I know, the namespace has to be set in code if that XML is within one or several namespaces.

Example: The x:Members node is assigned to the namespace x as shown at the end of my response here. And under this node each x:Property node is also assigned under the same namespace

Attached below is the Flow that I created . I hope this works for you. I have documented it as clearly as possible. Make sure to switch the path to your Main-copy.xaml file

Test_Read_Main_XAML_Params.xaml (15.5 KB)

Andy