Output Arguments of an Invoked Workflow (working with xml nodes)

Hello everyone,

I am new to this forum and hope that I can find some help here.

I am currently working on my own “Workflow Inspector”. As some of you might know, there is already an open accessible “Workflow Inspector RPA component in UiPath Connect” (https://connect.uipath.com/marketplace/components/workflow-inspector). I started with this component as foundation and I am adding custom checks that fulfill my requirements regarding coding standards.

Maybe a quick word on how the Workflow Inspector works (forgive me if I explained it wrong since I am not really experienced on working with xml nodes):
With the Workflow Inspector you can define some specific xml nodes which you want to analyze. With given check criteria it can perform checks on all relevant nodes. If some issues were spotted (check criteria not fulfilled), those issues are written into a report file.

The situation:
Part 1: Currently I am building a check which checks if a specific workflow file is invoked within the whole project (folder).
Part 2: If the correct invoke workflow file activity was identified, I want to output all invoked arguments to an array/data table (I want to store the information in an Excel file later).

Part 1 is already done.

For Part 2:
My idea was to take advantage of the Input (“Arguments” attribute) properties of the Invoke Workflow File activity since the arguments are stored there (I guess?). My attempt was to get the .Attributes(“Arguments”) list/array/collection (or whatever it is…I really don’t know) and convert it to something that I can use to output the data (e.g. Data table). The data type of this collection seems to be “System.Xml.XmlAttributes”.

Would that work somehow? If yes, how can I do it?

If my idea does not work, do you have an other solution to output the imported arguments?

Every help is much appreciated. Thanks!

2 Likes

Hello!

Inside the element that represents the Invoke Workflow File activity, there are children elements that represent arguments:

So you can iterate over those children, extracting their name and value, then adding that to a collection (maybe a dictionary of arguments for each invoked workflow?).

Note that the XML structure above changed in more recent versions of the activity, so arguments and their values are represented in a different way:

So to make it work for both versions, you’ll need two different ways to retrieve arguments and values.

1 Like

Hi @Mateus_Cruz,

thank you very much for your reply. At first I want to mention that I use Studio 2019.10.5.

I am exactly looking for the solution you mentioned (but I don’t understand exactly how to realize it technically).

I was assuming that I could somehow access the “Arguments” attribute where I assumed that all invoked arguments (and their values) are stored (see screenshot) and then write the information in a Data Table to write that down into an Excel Sheet.
2020-09-11 09_45_24-Window

Could you maybe explain in detail how I could access those children elements?

Unfortunately, as a new User I am not able to upload attachments. Maybe the screenshots help to understand how I’ve built the check.

Hello, I have watched now dozens of videos explaining how to read xml files. When I try to read those Ui nodes I will get an error:

For Each: The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name.

Can someone please help me? How can I read those “ui:…” nodes?

Here’s a sample showing how to do it: ExportInvokeWorkflowFileArguments.xaml (30.0 KB)
Add it to the Checks\Custom folder and update the Checklist.xlsx file to include it.
When it gets executed, it’ll create one CSV file for each Invoke Workflow File activity in the project’s folder.
It should cover both older and new versions of Invoke Workflow File activities.
A test project (made with UiPath Studio 2020.10): Invoke202010.zip (36.2 KB)

A summary of the steps:
1 - Get all ui:InvokeWorkflowFile.Arguments elements with the expression "//ui:InvokeWorkflowFile.Arguments"
2 - For each of these elements, get the name of the argument, its type and its value:
2.1 - The name is always in the attribute x:Key, so you can get it using ArgumentNode.Attributes("x:Key").Value
2.2 - The type is always in the attribute x:TypeArguments, so get it using ArgumentNode.Attributes("x:TypeArguments").Value
2.3 - In the case of older versions, the value is always in the inner text of the element, so get it using ArgumentNode.InnerText
2.4 - In the case of newer versions, the value can be in different parts of a child element (consider that ArgumentValueElement is a child of ArgumentNode):
2.4.1 - Value in the inner text of the child (for example, <Literal x:TypeArguments="x:String">Alice</Literal>), which can be retrieved by ArgumentValueElement.InnerText.
2.4.2 - Value in the Value attribute of the child (for example, <Literal x:TypeArguments="x:Int32" Value="25" />), which can be retrieved by ArgumentValueElement.Attributes("Value").Value.
2.4.3 - Value in the ExpressionText attribute of the child (for example, <mva:VisualBasicValue x:TypeArguments="x:Int32" ExpressionText="Age" />), which can be retrieved by ArgumentValueElement.Attributes("ExpressionText").Value.
2.5 - Save data about each argument (i.e., name, type and value) into a row of a DataTable, which gets output to a CSV file at the end.

It’s not a very clean workflow because I wanted to have everything in the same file to make it easier to share here, but it should get you started on what you want to do.

Also, note that there are no guarantees that the XML structure will remain the same in future versions of the activity.
If the structure changes, it’s probably necessary to modify this check as well.