From the course: UiPath Essential Training

Passing data to a process - UiPath Tutorial

From the course: UiPath Essential Training

Start my 1-month free trial

Passing data to a process

- [Instructor] Now that we've extracted that data from the application, what we need to do is filter the information that we have to only accept the items that are WI5 and the status of open. However, before we start doing that, I've just noticed that we need to tidy up the folder structure. I've got some ACME components which need to be placed into the ACME folder. I've got some ACME components which need to be placed into the ACME folder. Like so and we're good to go. So first things first, it's a good idea to separate out components. The different types components that we want to separate are either components that change screen, so if you're changing screen in an application, then you'll want to potentially create a new component. This is not always the case but it is generally a good advice. Additionally, it's a good idea to separate any logic from any UI automation. The reason for doing this is if we have some complex logic which is, for example, filtering the data table, we don't always want to have to go and navigate to that web page in the application in order to run the logic in the test. So by separating out the logic from the UI automation component, we're much more easily able to test further down the line. So we already have our component here, ACME Extract Work Items which extracts the data from the Work Items table. What we need to do next is create an argument out of this component which is going to pass the data table back to a process layer. Let's quickly do that by changing the variable that's being created, DTWorkItems, into an argument. So first create the argument and it's going to be out because we're passing the data table out of the component. We'll call it the same thing, DTWorkItems but we're going to have an out prefix. The direction of the argument will be out and there's no default value. Always remember to delete the DTWorkItems variable because we're now going to be using the out_DTWorkItems argument. Initially this will cause an error but we simply need to change any reference to DTWorkItems to the argument out_DTWorkItems. We can see that there's an error because there's a blue exclamation mark and if we hover over the exclamation mark, we can see what the error is. This actually says one ore more children have validation errors or warnings. If we go to the property of the data table, we can see that it says value of type string can't be converted to System Data.DataTable. So even though we've changed the variable to the argument, what's not correct is the type of argument. Let's change it. Data Table and the error will disappear. Additionally, we also have a reference to DTWorkItems in our log message which we also need to change to the argument name. Click off, errors disappear. So now what we can do is call that component or workflow from a process layer or from a different workflow. Let's go ahead and do that. Take an invoke workflow activity. Let's temporarily disable the ACME login component because we don't need that for the time being and also move the get Password into the ignored activities. Let's go and find our new component, Extract Work Items, press Open, Import Arguments and let's now create a new variable in our process layer called DTWorkItems. This will automatically be created as a data table type and to prove that the data coming out of that component is correct, let's put a very quick log message and let's print the number of rows that were passed out of that component in the out argument for DTWorkItems. Notice that we're using the variable DTWorkItems, not the argument because that's what we've passed it to in this process layer. And if you are struggling with the concept of arguments and variables, you're not alone, many people struggle with these concepts, so please use the community forum if you have questions specifically around arguments and variables or any other questions. So I'm just going to make sure we're in the right place in the Work Items page. Let's get back to page one. Okay, so let's run this process and see what results we get. Once again, the robot loops through the table and when the robot completes, we can take a look at the output. Now we'll see log messages, one from the component which is Data Table Out, DTWorkItems contains 107 and then in our process, we also have the same log message and the great news is that the number of rows in both tables matches perfectly. Now that we've got the data table in our process, next up we'll be creating a component which will filter the data giving us just those work items which are WI5 and status of open.

Contents