Search

How to upload documents to IDM using RPA

Business Problem

This tutorial explains how to upload documents into Infor Document Management (IDM) using the IDM API endpoint deployed on API Gateway. The flow outlined in this tutorial can also be used with the Read Key-Values flow to make the extracted values become the attributes of the uploaded documents.

Components

  • RPA Management
  • RPA Studio
  • Infor Document Management
  • Infor API Gateway

Requirements

Before Starting

Before we start building, be sure to complete the following steps:

  1. Make a folder for all the files you want to upload (e.g., C:\RPA\IDM).
  2. Create a new document type in IDM (e.g., DocumentUpload with one attribute: ScreenID).
  3. Install RPA Studio and establish a connection between RPA Studio and RPA Management by using the connection files from API Gateway. Check the Infor RPA Studio User Guide for full instructions.

Tutorial

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 RPA Studio home page, click Create New Project and specify the following properties in the pop-up window:

  • Name: UploadDocumentToIDM
  • Project Location: <default>
  • Description: Simple document upload to IDM
  • Language: VB <selected by default>

3- Add the activity Get Files Directory. This allows RPA Studio to read all the files in the selected directory. Then, under System Category, select Activities. Drag and drop the activity on the Design canvas and click on it. The properties of the selected activity will appear in the properties panel. Configure the properties in the following way:

  • For Path, direct  IDM to the files you want to upload with an argument called FilePath of type string and default value of the directory path “C:\RPA\IDM”.
  • For Files, let’s create a variable that will store the list of the file paths: called FileList of type List  <string> without any default value.
  • To find List <String> data type, expand the Variable Type and select Browsefor Type. For Type name cell, type List andselect List under the System.Collections.Generic domain.

4- Next, we need to create the logic to call an IDM Endpoint for each of the read files. For that, we need to drag and drop the activity For Each and configure it in the following way:

  • Select the String data type for the propertyTypeArgument,since the file path we want to read is represented as a String.
  • For Value,specify the FileList.
  • On the main canvas, you should see the following phrase: “For each item in FileList.” It is recommended to change item to file so it is clear what is being read.

5- In the For Each activity Body field,drag and drop the Sequence activity where we will add the next set of activities. Note thatwithout the Sequence activity you can only add one activity as part of the For Each activity body.

6- To send the document to IDM via API endpoint, it must be 64 base encoded. For that, add File to Base64 String activity which is part of the System activities category. Configure its properties in the following way:

  • For FilePath, specify file which represents the file path read from directory.
  • For Base64String, create a variable called filebase64 of type String. It will store the base64 encoded file.

7- Next, we will add the Assign activity and define the logic to store the file name as a variable. Later, we will use this property as a dynamic variable for the Endpoint Request payload. Let’s configure its properties in the following way:

  • For To, create the variable FileName of type string.
  • For Value, specify the VB expression to get the file name: System.IO.Path.GetFileName(file).

8- Next, create the payload for the API Endpoint for POST method which will allow the documents to be posted into IDM with specific values. For that, we need to add the Templating Activity part of the System category for the activities. Let’s configure its properties in the following way:

  • For the Values property, input the list of the variables used as part of the Template property. In this example it would be FileName and filebase64. To configure the property, click “… ”
    • In the popup window for Key input, enter the name of the variable you will use in the Template property to create the payload for the API Endpoint. For Value input, enter the variable name holding the previously generated value, as defined in the Variable panel.
    • If a different variable name is used in the Template property, the Key name must be changed accordingly.
  • For Template, input the payload which would be posted via API Endpoint. Make the following transformations to the payload:
    • Use single quotation marks (‘) instead of double quotation marks (“), as the value for this property should be a string and enclosed between a set of double quotations.
    • Encode the dynamic variable in the following way: {{%variablename%}}
      • If a variable is an integer, write it without single quotation marks (‘), otherwise, it will be treated as a string.
      • In this example, all the values we are passing should be treated as strings, so enclose the variable within single quotation marks (‘).
    • Example payload: {‘item’: {‘attrs’: { ‘attr’: [ {‘name’: ‘ScreenID’, ‘value’: ‘1000MR’} ] }, ‘resrs’: { ‘res’: [  { ‘filename’: ‘{{%FileName%}}’, ‘base64′:'{{%filebase64%}}’} ] }, ‘acl’: {‘name’: ‘Public’ },’entityName’: ‘DocumentUpload’} }
    • The actual payload is supposed to be in JSON format. However, since double quotations cannot be used, they must be replaced with single quotations. Moreover, the dynamic variables in the payload are ” {{%filebase64%}} and {{%FileName%}}
  • For Text, which will store the payload with the correct values populated, let’s create the variable: TemplateOutPut of type String.

9- To use the created Text property output TemplateOutPut in the ION API Request, we need to transform it into JSON format. For that, drag and drop the Deserialized JSON activity and configure it in the following way:

  • For JToken String, input the value created from the Templating activity as the variable: TemplateOutPut.
  • For JToken Object,create the variable which will store the JSON payload: IONAPIPayload of type JToken.
    • To select the JToken data type, click on the Variable Type. In the drop down select Browse for Types. Then, type “Jtoken” in the Type Name text field and select JToken under Newtonsoft.Json.Linq.

10- Now that we have a variable storing the JSON payload to post part of the API call, we can create the final API request to post the document. For that, drag and drop the IONAPI Request activity part of IONAPI activities’ category and configure the activity in the following way:

  • For Method,select POST
  • For URL, create the following argument:
    • Called EndpointURL of type string and default value of endpoint whole URL (e.g. https://mingle-ionapi.inforcloudsuite.com/TenantName/IDM/api/items).
      • The default value should be between the quotation marks as it is of String type.
      • The URL called as part of this activity should point to the same tenant you are logged into.
  • For Content Type,make sure application_json is selected.
  • File Attachments, Headers will stay empty.
  • For POST Data,input the variable which was an output of the Deserialize JSON activity, IONAPIPayload.
  • Since this endpoint doesn’t have any Query Parameters, the Query Parameters property will remain empty.
  • For Response, you can create the following variable for troubleshooting:
    • Called Response of type ResponseObject. To select the ResponseObject data type, click on the Variable Type. In the drop-down menu, select Browse for Types. In the Type Name text input field, type ResponseObject and select ResponseObject under Infor.RPA.Utilities.   

11- As an optional step for troubleshooting, you can add Message Box as the last activity of this sequence to read the API Response and see if the document was uploaded successfully. Let’s configure the activity in a following way:

  • For Input Text,define the VB expression which will read the response from the API call. To do this, use the variable Response which is the output of the previous activity and specify the following VB expression: Response.ReadAsText.
  •   The reason for the properties may remain empty.

Note: Before pushing the flow into production, make sure that the Message Box activity was removed. 

Now you can run the flow and check the logs and uploaded file!

RPA Activities List

Downloadable Resources