How to create an RPA flow using System activities
Beginner | 15 Minutes
Overview
This tutorial will show you how to create a basic flow using system automation and workflow activities.
Let’s create a flow which will allow a bot to read files and check if they contain any text. The text will then be written into a logfile, which will be created upon running the RPA flow.
📋 Requirements
|
Tutorial
1
Save flow
Now, save your flow. Click Run to execute and verify that the user is successfully navigated to the required Invoice Creation screen in the M3 application.
2
Create new project
On the Home page of RPA Studio, click Create New Project and specify the following properties in the pop-up window:
- Name: ReadFilesinDirectory
- Project Location:
<default> - Description: Read Files in Directory
- Language: VB (selected by default)
3
Create log file
Start the flow by creating the log file, where you will store the summary of the action (i.e., the read file path and the findings if the file was empty or had content). From the Activities side panel, drag and drop the Create File activity. Click on the activity on the design canvas and set up its properties. For that, we will first create a few arguments which can later be referenced in the activity properties.
- For Target Filename, which should contain the name of the logfile and its extension, create an argument called logfilename of type string with the default value: "logfile.txt".
- For Target Filepath, which is the path of the file where the logfile should be stored, create a second argument called logfilepath with the default value: "C:\RPA\LogFile".
- For File Output, we can create a variable instead of the argument. This variable will store the entire path of the created log file (directory it is in + the file name) called outputfilepath of type string without any default value.
4
Add ‘Get Files in Directory’ activity
Configure the flow to start reading the files in the directory. To do this, drag and drop the Get Files in Directory activity. Define the following values for its properties:
- For Path, which will hold the information about which directory to access, create an argument called
Pathof type string with the default value"C:\RPA\SystemActivities". - For Files, which will hold the list of files, create a variable called
filesof type List (System.Collection.Generic.List). To find the List <String> data type, expand the Variable Type dropdown and select Browse for type. In the Type name cell, typeListand select List under the System.Collection.Generic domain. Once selected, below the System.Collection.Generic.List dropdown, select String and click OK.
5
Create For Each to read files
Create a loop so that the RPA process can read each of the accessed files in the loop one by one and perform an action. For that, add the For Each activity and define its Type property as String.
6
Logic addition
Create logic so that for each “item in the list of the files,” where files are represented by the variable files, we will read the file. In this case, in the Value property, specify the files variable.
7
Add a Read a File activity
Specify the following Read a File properties:
- For Source Filepath, the property should be the item as defined in the loop component.
- For the Text property, which holds the text read in the .txt file, create a variable called text of type string.
8
Create a Condition activity
Now, the RPA flow should perform a different action depending on whether the file has content or is empty. For that, we need a Condition activity (if).
In the If activity, we can define that:
- If text = "" (which translates to if the file has no content), proceed with the following steps:
9
Write findings in log file
We would like to write this discovery into the logfile. For that, we need to use the Append Line activity with the following properties:
- For Line, specify:
item + " this file is empty". - For Source Filepath, specify the
outputfilepathvariable.
Else, if the file contains text, we will also write it into the logfile using the Append Line activity with the following properties:
- For Line, specify:
item + " this file has text". - For Source Filepath, specify the
outputfilepathvariable.
Now you can test by triggering it. Click the Run button in the toolbar above the design canvas.
Logs
Once the RPA process is run, you can check the logs in the Output Page of RPA Studio. If the activities were executed without throwing any errors, the status code will be 200, meaning it was executed successfully. Otherwise, if the code is 401, 402, 500, or another error code, it means there was an issue executing a particular activity.
Flow Improvements
Now you can improve the flow by tackling a possible exception scenario: the logfile already exists.
- To handle this, use the Path Exist activity, where:
- For Path, use the
outputfilepathargument rather than the variable, as it can be different depending on where the process is run. Provide a default value:"C:\RPA\LogFile\logfile.txt". - For IsValid, create a new variable called
logfileexistsof type Boolean.
- Add a Condition activity with the property logfileexists:
- If True, do nothing.
- If False, create the file by moving the Create a File activity into the Else body.
Now you can run the flow again to handle the scenario where the logfile exists.
Activity List
The following System and Workflow activities were used in this tutorial:
What made this section unhelpful for you?
On this page
- How to create an RPA flow using System activities