Search

How to create an RPA flow using OneDrive activities to download files

Overview

This tutorial will show you how to create a basic flow using few of the OneDrive Activities. We will create a flow to download the documents/ files from OneDrive Folder and moving them to a different folder.


Components

  • RPA Management
  • RPA Studio
  • OneDrive access (Office365)

Requirements

  • Before you can start building the flow, you’ll need to install RPA Studio on your machine and set up a connection between the RPA Studio and RPA Management. Check the Infor RPA Studio User Guide for the steps on how to do it.
  • Meet the prerequisites for using the MS Office 365 graph activities:
  • Create the RPA Application in Azure tenant following the steps listed in: Register an application with the Microsoft identity platform – Microsoft Graph | Microsoft Learn
  • Create the MS Office 365 Oauth provider in RPA Management
  • Authorize the application in RPA Management
  • Note: All the above steps are part of the RPA User Guide
  • Create a folder on your local disc called e.g. Attachments having the following path: C:\RPA\Attachments
  • Create 2 OneDrive folder:
    • 1st called : Demo_RPA_OneDrive_Move
    • 2nd called: Demo_RPA_Onedrive_Write
  • In the Demo_RPA_OneDrive_Write add few files which will be downloaded.

Tutorial

Difficulty: Medium
Estimated completion time: 25 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 popup window:
    1. Name: OneDrive Download Move
    2. ProjectLocation: <default>
    3. Description: OneDrive flow to download the Files from the OneDrive Folder and move the to a different one.
    4. Language: VB <selected by default>
  1. We will start our flow by getting the files from the OneDrive Folder which we will be downloading. For that look for Find Files or Folders activity part of the One Drive Category and drag and drop it on the design canvas and set up its properties. For that we will first create few arguments which later/ variables can be references in the activity properties.
  • Note: To use this activities and OneDrive activities you need to create Oauth provider MS Office 365 as listed in pre-requisites.
  • For  Subfolder property which should contain the name of the folder from where we will read the files. let’s create an Argument:
    • called ReadFolder of type: string and default value: “Demo_RPA_Onedrive_Write”   
    • Note: If left empty bot will read the files from the Root Folder. if you which to read a files from a folder which is nested specify the following path “Folder/SubFolder/ …”
  • Query property should stay empty
  • For Item, we can create a variable instead of the argument, it will store the first item id found the read folder
    • called Item1 of type OneDriveItem
  • For Results we can create a variable instead of the argument. This variable will store the list of items id found in the folder.
    • called Itemlistof type: OneDriveItem[] without any default value, which translates to Array of OneDriveItem
      • to find OneDriveItem[] data type expand the Variable Type and select Array of [T]. Next in the Select Types pop’up expand the dropdown under T value and click Browse for Type, and in the Type Name cell type OneDrive and select OneDriveItem under the Infor.Activities.OneDrive.Model domain Click OK and Clikc OK again.

4. Next, we will get the folder where the files should be moved. For that we will use the same activity as previously Find Files and Folder , but configure it differently.

  • For  Query which is a filter for finding the exact Folder to read we will create an Argument:
    • called MoveFolder of type: string and default value: “Demo_RPA_OneDrive_Move”   
  • Subfolder property should stay empty as we will be looking for the folder inside of the root folder of OneDrive.
  • For Item, we can create a variable instead of the argument, it will store the first item id found the read folder
    • called Move1 of type OneDriveItem
  • For Results we can create a variable instead of the argument. This variable will store the list of items id found in the folder.
    • called Movelist type: OneDriveItem[] without any default value, which translates to Array of OneDriveItem
      • to find OneDriveItem[] data type expand the Variable Type and select Array of [T]. Next in the Select Types pop’up expand the dropdown under T value and click Browse for Type, and in the Type Name cell type OneDrive and select OneDriveItem under the Infor.Activities.OneDrive.Model domain Click OK and Clikc OK again.

5. Next, we will create the loop to store each of the read file and move it to the different OneDrive Folder once downloaded. For that we need to add For Each activity and specify the following:

  • for Type property as OneDriveItem which is same as a single object type from the Itemlist variable
  • for value property define Itemlist.
  • In the activity on Design Canvas You will see the following text “Foreach item in Itemlist” the item signify the single object in this example mail within the list of object, here list of file paths

6.Inside For Each Block we will add a few activities. A Sequence activity is needed inside of the For Each block in order to be able to do that.

7. Inside of the Sequence block let’s add Download File activity to Download the OneDrive Folder and saved them in the File directory on the local system by specifying the following properties of this activities;

  • for Download location, where the file(s) should be downloaded, we can create the argument,
    • called DownloadFolder of type string and default value e.g. “C:\RPA\Attachments”
  • for File To Download, which is the path of the downloaded file or folder, define item which is the one specified in the For Each block

8. As the last step we will define the activity o Move the downloaded file do a different OneDrive folder. For that look up Move File or Folder activity and drag and drop it inside to if the Sequence block inside For Each activity and specify its properties in a following way:

  • for File or Folder to move specify the item, same variable as in the For Each activity
  • for Destination Folder specify the variable Move1 which is the output from the Find Files or Folders activity

Activities List