Overview

Sections

How to create an RPA flow using System activities

Beginner | 15 Minutes

RPA

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

  • The user needs access to 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 RPA Studio and RPA Management, meaning the on-premise component and Multi-Tenant component by using the connection files from the 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 a few artifacts needed to set up an RPA flow:
  • Create one folder called SystemActivities (e.g., the folder path C:\RPA\SystemActivities).
  • Within the created folder (C:\RPA\SystemActivities), create 3 .txt files:
  • Test1.txt
  • Test2.txt
  • Test3.txt
  • For Test1.txt and Test3.txt, add the text “I have text.” and leave the Test2.txt file empty.
  • Create a folder called LogFile (e.g., the folder path C:\RPA\LogFile).

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 Path of type string with the default value "C:\RPA\SystemActivities".
  • For Files, which will hold the list of files, create a variable called files of 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, type List and 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 outputfilepath variable.

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 outputfilepath variable.

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.

  1. To handle this, use the Path Exist activity, where:
  • For Path, use the outputfilepath argument 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 logfileexists of type Boolean.
  1. 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:

Was this section helpful?

What made this section unhelpful for you?

On this page
  • How to create an RPA flow using System activities
View as Markdown

Ask an AI

Open in ChatGPTOpen in Claude