+
+

Lab 6: Invoke Published Document Action within an RPA Automation

Overview

In this lab you’ll learn how to invoke, from an RPA automation, an IDP Document Action previously published to RPA.

As part of the exercise you’ll start from a pre-drafted automation and you’ll be asked to complete it. The automation polls an email inbox for a new email and when founds an email sends (POST) the attachment to IDP. The application then polls for the results every 5 seconds and once available prints them out.

Following you see the drafted automation you’ll be working on.

module g  draft automation

Prerequisites

If you didn’t complete Lab 1: Process an Invoice with MuleSoft IDP , in order to be able to consume the NTO Invoice Document Action in RPA, you have two options:

  • Use the document action published by one of the other workshop attendee.

  • Quickly create a new <your-initials> - NTO Invoice document action (leave everything set to the default) and publish it to RPA.

Step 1: Create and Release a New Process up to the Build Phase

  1. Logon to your MuleSoft RPA Manager instance.

    Expand the Process Automation menu and click on Process Management

    module g  rpa man prc aut menu
  2. Click on your workshop category to start building your new Automation process.

    module g  category tile
  3. Once in your category, click on the Create button

    module g  create prc btn
  4. Use the following pattern for the process name:

    <your-initials> - IDP Module - Process Document with IDP

    module g  prc wiz name

    Scroll down and uncheck the Use Process Board option (we will not use the Process Board capabilities on this workshop).

    module g  prc wiz prc board

    Click Save on the bottom right to create your new automation process.

    module g  prc wiz save btn

    Open your new process by clicking on its name

    module g  prc tile

    Every new process starts on the Design phase. On this module we will not cover it so we need to move it forward to the next one: Build

  5. To move forward the current process phase, click on the Publish button:

    module g  pub to build btn
  6. Every time a process is moved forward its following phase, a confirmation popup window is shown. Check the confirmation option and click the Release to Build button:

    module g  rel to build wiz
  7. Now the process is in Build phase and ready to be implemented with the MuleSoft RPA Builder tool

    module g  lifecycle path build

Step 2: Download and Open the Process with RPA Builder

  1. Once RPA Builder is opened, click on the Repository Explorer tab. The explorer, you should see a number of processes that are currently in Build phase. Locate your process and double click to open it.

    module g  repo explorer
    Important

    Make sure you locate and open YOUR process. Remember you should have used the following pattern to name it at the previous step:

    <your-initials> - IDP Module - Process Document with IDP

    If the Repository Explorer tab is not displayed, you can always enable it by going to the View menu and clicking on Show Repository Explorer:

    module g  show repo explorer
  2. After double clicking your process, it will be downloaded from the server and stored locally in the Windows box.

    1. If a dialog box pops-up asking to change the resolution, click Yes

Step 2: Import a Pre-drafted Process

  1. From the Windows VM, download the Module_IDP_Lab_6.crpa file containing the drafted automation.

    You should have the Google Drive link sent to you along with the credentials and other workshop material. This drive contains the student files and solutions for all Labs. If you do not have access, ask the instructor.

  2. In RPA Builder, click the Import Project option under the File menu:

    module g  import rpa project
  3. Click Yes to Confirm project will be overwritten dialog, locate your just downloaded .crpa file and click Open to import it.

Step 3: Configure the Imported Process

  1. Locate and click the Business Process Initialization button at the top right of the Canvas and click on the Activity Parameters link:

    module g  rpa buz proc init
  2. Update the mail settings with values provided by the instructor. Only the mailCredentials password should be missing.

    module g  rpa password activity parm 3 2
  3. Update the idpConnectApp Client ID & Client Secret, provided by the instructor

    module g  update connected app 3 6
  4. Double-click on the existing Check Email activity and its configuration window will be opened below:

    module g  bpmn check email activity 3 3
  5. Double-click on the Read Email element.

    module g  read email element 3 4
  6. Update (replace CC with yours initials) the subject email filter with this pattern <your initials>-.

module g  update subject email filter 3 5

Step 4: Post Document to IDP

  1. Double-click Process Document with IDP activity and its configuration window will be opened below:

    module g  bpmn process document activity 4 1
  2. In RPA Builder, click the Show Toolbox option under the View menu:

    module g  show toolbox menu 4 2
  3. From the toolbox, locate and drag the Submit Document to MuleSoft IDP action step to the Activity Workflow workbench

    module g  submit document element 4 3
  4. Double-click the Submit Document to MuleSoft IDP element

    1. Assign the Execution ID to the Activity Parameters→idpExecutionId

    2. Select YOUR Document Action for the Action and leave the default version

    3. For Directory Path click the Push Pin and select the Activity Parameters→attachmentsTemporaryFolder

    4. For File name, click the Push Pin and select the Activity Parameters→attachmentFilename

    5. Set the Connected App Credentials to the Activity Parameter→idpConnectedApp

    6. Click OK

module g  submit document wizard 4 5

Step 5: Get IDP Results

  1. Double-click Retrieve IDP Processing Results activity and its configuration window will be opened below:

    module g  bpmn retrieve idp activity 5 1
  2. From the toolbox, drag the Retrieve Results from MuleSoft IDP action step to the Activity Workflow workbench

    module g  retrieve idp element 5 2
  3. Double-click the Retrieve Results from MuleSoft IDP element

    1. Assign the Execution ID to the Activity Parameter idpExecutionId

    2. Select your Document Action for the Action and leave the version as the default

    3. Set the Connected App Credentials to the Activity Parameter idpConnectedApp

      module g  retrieve results wizard 5 3
  4. From the toolbox, drag the Set Variable action step to the Activity Workflow bench under the Retrieve Results from MuleSoft IDP element.

  5. Double-click the Set Variable element.

    1. In the Name field type Set IDP Status.

    2. For the Variable field select the Activity Parameter idpStatus.

    3. For the Value field, click the push pin and select Retrieve Result from MuleSoft IDP→Status.

    4. Click OK.

      module g  set status element 5 5
  6. From the toolbox, drag the Json Query action step to the Activity Workflow below the Retrieve Results from MuleSoft IDP element

  7. Double-click the Json Query element

    1. In the Name field type Get Invoice Number

    2. Set the Json Object to Retrieve Results from MuleSoft IDP→Json Result.

    3. For the JsonPath Expression click the braces { }

      module g  json query element 5 7
    4. Click Import from file and navigate to the Module_7_files folder and select the IDP_Sample_Output.json file

      module g  json query import 5 7 b
    5. Click Next.

    6. You will be shown a sample output

    7. Click "value" under "invoiceNumber", this should auto-populate the JSONPath Expression field with $.pages[*].fields.invoiceNumber.value and the Result field with 100

    8. Click Next, then click Apply, then click OK in the Json Query Wizard.

      module g  json query import 5 7 g
  8. Repeat steps 9-13 for Invoice Date, Invoice Purchase Order, Invoice Due Date and Invoice Total.

    module g  json query repeat 5 8
  9. From the toolbox, drag the Set Variable action step to the Activity Workflow workbench below the Get Invoice Total element.

  10. Double-click the Set Variable element.

    1. In the Name field type Set Invoice Number

    2. For Variable select the Activity Parameter, Invoice Number

    3. For the Value, click the push pin and select Get Invoice Number→FirstItem

    4. Click OK.

      module g  set variable invoice number element 5 10
  11. Repeat steps 15-16 for Invoice Date, Invoice Purchase Order, Invoice Due Date and Invoice Total.

module g  set variable repeat 5 11

The Automation configuration is complete. Move on to the next lab.

Step 6: Test the automation

  1. In the BPMN editor panel click Run Process icon. This will start the automation.

    module g  bpmn run process 6 1
  2. Activities 1 and 2 will run through completion. Activity 3 will show Please complete the User Task dialog box.

    module g  user task dialog 6 2
  3. Open chrome and navigate to https://anypoint.mulesoft.com/idp/tasks. Login using the credentials provided by the instructor.

    1. Under Review Tasks find YOUR document and select it. This should show your Invoice in the preview panel and paymentTerms in the Results panel.

    2. Review the Results panel and verify the accuracy. Click Submit and Done.

      module g  idp document review 6 3
    3. Go back to the User Task dialog box and click OK. This will continue the automation.

  4. A Message Box will be displayed with the extracted data from the Invoice. Wait for it to timeout or click Close..

    module g  print results messagebox 6 5
  5. The automation is complete, click Close in the Test run information dialog box.

module g  test run dialog box 6 5
Submit your feedback!
Share your thoughts to help us build the best workshop experience for you!
Take our latest survey!