Oracle by Example brandingBuilding and Testing the Orchestration

section 0Before You Begin

This 60-minute Oracle by Example (OBE) shows you how to build and test the orchestration.

What Do You Need?

To perform the steps in this OBE, you must have used process recorder to create a Form Request that updates the existing expense report with a new expense and add to an orchestration as explained in the preceding OBE.


section 1Building and Testing the Final Orchestration

  1. In Orchestrator Studio, you should already be on the orchestrations page, if not, select Orchestrations from the home page.
  2. Click New.
  3. Enter the name: OCI receipt to E1 Expense.
  4. Click the Start node and select File Inputs tab.
  5. Select Process Files Individually.
  6. Enter a * in the File Name Pattern.
  7. Let the Variable Name default to fileName_0.
  8. Enable the Overwrite Existing Files option (so the file name stays the same).
    Description of img29.png follows
    Inputs and Values for Orchestration
  9. Select the Variables tab, enter these three variables:
    1. compartmentId – populate the default value with your OCI compartment ID.
    2. bucketName – populate the default value with the bucket name (in prerequisites).
    3. nameSpace – populate the default value with your OCI namespace.
    4. Description of img30.png follows
      Variables tab
  10. Save the orchestration.
  11. Double-click the line between the start and end node and select Connector.
  12. Enter PUT Object File to find the connector.
  13. Click the new connector node and select Transformations.
  14. Select the orchestration variables for namespaceName and bucketName.
  15. Select fileName_0 for both objectName and fileName.
    Description of img31.png follows
    Transformations
  16. Save the orchestration.
  17. Test the orchestration so far.
  18. You will be using the WalmartReceipt1.jpg image of the receipt for testing, download the image file locally.
  19. Description of img32.png follows
    Walmart Receipt
  20. Double-click the Start node to open the Run Orchestration window.
  21. Click the Files button, click the box or drag and drop the WalmartReceipt1.jpg file to send it into the orchestration.
  22. Description of img33.png follows
    Drag and Drop the Receipt
  23. Click Run. The orchestration runs, returning a Status OK (200).
  24. Description of img34.png follows
    Run the Orchestration
  25. Open your bucket in OCI, you will see the file uploaded.
  26. Description of img35.png follows
    Open bucket in OCI
  27. Close the Run Orchestrations window.
  28. Double-click the line after the first step, select Connector.
  29. Select OCI Document Key Values.
  30. Click the new node, select Transformations and map the following:
    • namespaceName= nameSpace(Variables)
    • bucketName = bucketName (Variables)
    • docToProcess = fileName_0
    • compartmentId = compartmentId (Variables)
    • nameSpace = nameSpace (Variables)
  31. Click Back on the diagram, and then click the End node and select Outputs and Assertions.
  32. Enable the following:
    • fileName_0
    • lifecycleState
    • percentComplete (change this to a Numeric value)
    • timeFinished
    • Response Status
  33. Save the orchestration.
  34. Test the orchestration so far, by opening the Run Orchestration window from the start node.
  35. Add the WalmartReceipt1.jpg to the files and click Run. The orchestration runs, returning a Status OK (200).
  36. Description of img36.png follows
    Run the Orchestration
  37. In OCI, view your bucket. You should see a new folder structure with a .json file.
    Description of img37.png follows
    json file

    If you download the file, you’ll see it has the results of the document understanding API, at the bottom it has identified it as a receipt.

    Description of img38.png follows
    Results of document understanding API

    The next steps in the orchestration will return these results to use them in the orchestration.

  38. Close the Run Orchestrations window.
  39. Double-click the line before the end node and select Logic Extension, select Build Object Name.
  40. Click the new node and select Transformations. Map the inputs as follows:
    prefix = prefix
    id = id
    namespace = nameSpace
    orig_bucket = orig_bucket
    orig_name = orig_name

    The Available Values are outputs for the OCI Document Key Values, except for nameSpace (variable).

    Description of img39.png follows
    Inputs and Available Values for OCI Document Key Values
  41. Click the orchestration End node and select Outputs. Enable the objectName in the outputs.
    Description of img40.png follows
    Outputs
  42. Save and test the orchestration again. The objectName should have a value similar to this example, but with your bucket name (that is jde-oci-documents). The following screenshot shows the path to the .json file we saw above.
    Description of img41.png follows
    Path to the .json file
  43. Close the Run Orchestrations page.
  44. Double-click the line before the end node, select Connector, then select Get Key Value Object JSON.
  45. Click the new node and select Transformations. Map the following:
    Description of img42.png follows
    Transformations
  46. Click back to the diagram, click the end node and select Outputs.
  47. Enable all the values from the new step and rename them as necessary. The following screenshot shows the values used to complete the tasks in this OBE:
    Description of img43.png follows
    Enabling and renaming the values
  48. Save the orchestration and test again. The output should now include details found in the receipt, the result of the Document Understanding service.
    Description of img44.png follows
    Outputs
  49. Close the Run Orchestrations window to continue building the orchestration.
  50. Double-click the line before the end node and select Connector.
  51. Select OCI Delete Object. Now that the receipt has been evaluated the orchestration will delete it from the bucket.
  52. Click the New node and select Transformations. Map the following:
    namespaceName = namespace
    bucketName = bucketName
    objectName = filename_0
    Description of img45.png follows
    Transformations
  53. Double-click the line before the end node and select Logic Extension.
  54. Select ExtractFieldValues.
  55. Map the transformations, matching the two values from outputs of the Get Key Value Object JSON.
    Description of img46.png follows
    Map the transformations
  56. Click the end node and select Outputs.
  57. Add the values from the two new steps (changing names as needed). The following screenshot shows the values used to complete the tasks in this OBE:
    Description of img47.png follows
    Add Values
  58. Save the orchestration and test again. The output should include a status (204) for delete and the three values from the receipt.
    Description of img48.png follows
    Verifying the Output
  59. Check your bucket in OCI, the receipt .jpg file should no longer be there.
  60. Close the Run Orchestrations window to continue building the orchestration.
  61. Click the start node and select Inputs and Values.
  62. Add two inputs:
    • expenseReportNumber, Numeric (set the default value to the expense report you created)
    • expenseCatagory, String (set the default to MISC)
    Description of img49.png follows
    Inputs and Values
  63. Double-click the line before the end node and select Orchestration.
  64. Select AddExpenseToReport.
  65. Map the transformations as follows, with the number and category returned from the inputs and the expense date, amount, and merchant returned from ExtractFieldValues step.
    Description of img50.png follows
    Map the transformations
  66. Enable the output of report number for the new step in orchestration outputs.
    Description of img51.png follows
    Enable the output
  67. Save the orchestration and test again. The report number should show in the output.
    Description of img52.png follows
    Report Number in Output
  68. Now return to EnterpriseOne, Expense Entry.
  69. Find and select your report. A new line should be added with the date and amount from the receipt.
    Description of img53.png follows
    Expense Entry Report
  70. Click the MISC link for the line to open the record and view the Additional tab. The merchant’s name (Walmart) should be in the record.
    Description of img54.png follows
    MISCELLANEOUS Information
  71. The orchestration successfully used the OCI Document Understanding service to gather details from a receipt and those values were entered into an EnterpriseOne expense report.

Conclusion

In this learning path, you have learned how to:

  • Use a Document Understanding in OCI to find key values in a receipt image.
  • Create an Orchestrator connection with authentication and endpoint definition to the OCI Object Storage API and OCI Document Understanding API.
  • Create a connector to put the receipt image in Object Storage.
  • Create a connector to call the Document Understanding service to find key values in the uploaded image.
  • Create a connector to download the JSON that is the result of the Document Understanding service.
  • Create various orchestration steps to gather the information from the result, add it to EnterpriseOne records and attachments.

You can use these skills and a similar approach to call many of the OCI APIs using orchestrations.