Search

How to create an RPA flow using System activities

Business Problem

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 then would be written into a logfile which would be created upon running the RPA flow.


Components

  • RPA Management
  • RPA Studio

Requirements

  • The user needs access the cloud tenant via login.
  • Before creating the RPA Flow, you need to install RPA Studio on your machine and set up a connection between the RPA Studio and RPA Management meaning the on-premis component and Multi-Tenant component by using the connection files from API Gateway. Check the Infor RPA Studio User Guide for the steps on how to do it.
  • Before we start building the flow, let’s first create few artifacts needed to set up an RPA flow
    • Create one folder called SystemActivities e.g. of the Folder path C:\RPA\SystemActivities
    • Within the created folder (C:\RPA\SystemActivities) create 3 .txt files e.g.
      • Test1.txt
      • Test2.txt
      • Test3.txt
    • For Text1.txt and Text3.txt files, add the text “I have text.“ and leave the Test2.txt file empty.
    • Create a Folder called LogFile e.g. of the Folder path C:\RPA\LogFile.

Tutorial

Difficulty: Easy
Estimated completion time: 15 Minutes

  1. Open RPA Studio on your machine. If you are not signed in already into the Tenant you would be asked to sign in before proceeding to RPA flow designer screens.
  2. On the Home page of RPA Studio click Create New Project and specify the following properties in the pop’up window:
    1. Name: ReadFilesinDirectory
    2. ProjectLocation: <default>
    3. Description: Read Files in Directory
    4. Language: VB <selected by default>
  1. Start the flow by creating the log file, where you will store the summary of the action, meaning the read file path and the findings if the file was empty or had any 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 few arguments which alter can be references in the activity properties.
  • For  Target Filename property which should contain the name of the logfile and this extension, let’s create an Argument:
    • called logfilename of type: string and default value: ”logfile.txt”   
  • For  Target Filepath which is path of the file where the logfile should be stored, let’s create a second Argument:
    • called logfilepath with default value: ” C:\RPA\LogFile””
  • For File  Output file we  will 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
  1. Configure the flow to start reading the files in the director. For that let’s drag and drop the Get Files in Directory activity. For this activity let’s define the following values for its properties
  • for Path property which will hold the information which directory to access, create :
    • Argument called Path, of type string with default value “C:\RPA\SystemActivities”
  • for the Files property, which will hold the list of the files
    • Variable called files  of type List (System.Collection.Generic.List )
      • to find List <String> data type expand the Variable Type and select Browse for type. In the Type name cell type List and select List under the System.Collection.Generic domain. Once selected, below the System.Collection.Generic.List from the dropdown select the String and click ok.
  1. Create a loop so that RPA Process can read each of the access files in the loop one by one and perform an action. For that let’s add the activity called For each and define its type property as String.
  2. Create a logic that for each “item in list of the files” where files is represented by variable files, we will read the file. In that case in Value property we need to specify files variable
  1. Next we would like to add the logic that we would like to read each of the files. In that case we need a new automation activity called  Read a file.
  2. Specify the following Read a file properties:
  • for Source Filepath property  should be item as we defined in the loop component
  • for the Text property which holds the text read in the .txt file, let’s create a variable
    • called text of type string
  1. Now the RPA flow should perform a different action depending if the file had a content or was empty. For that we would need a condition activity if.
  2. In If activity property we can defined that:
  • if “text = “” which translates to if the file had an empty text within

Then we would like to write this discovery into the logfile. For that we need to use Append line activity with following properties:

  • for Line  property specify : item+” this file is empty”
  • for Source Filepath property specify the outputfilepath variable .
  • Else, so if the file contained the text, we will also write it into Logfile using Append Line activity with following properties:
    • Line property specify: item+” this file has text “
    • for Source Filepath proprty specify the outputfilepath variable .

Now you can test by trigger it. Click on the Run button in the toolbar above the design canvas.

Logs

Once the RPA process is run, in the Output Page of the RPA Studio you can check the logs if the activities were executed without throwing any errors. If the activity code is 200 it means that it was executed successfully otherwise if the code is 401, 402, 500 or other it means that there has been an issue while executing a particular activity.

Flow Improvements

Now you can improve the flow by tackling one possible exception scenario, which is the possibility of logfile being already there.

  1. For that we will use the activity Path Exist where
  • for Path property is the: outputfilepath
    • which we will change to be the Argument rather than variable as it can be different depending on where the process is run with provide default value: “C:\RPA\LogFile\logfile.txt”
  • For IsValid property we will create a new variable logfileexists of type Boolean.
  1. Now we need to add a condition activity IF and Condition property specify logfileexists , meaning  If log file exists
  • IF Then, than do nothing as it is TRUE,
  • IF Else, create a file, for that just move the Create a text file activity into this body.

Now you can run the flow again to see if it tackles the scenario where the logfile exists.


Activity List

The following System and Workflow activities were used in this tutorial: