Pre-General Availability: 2024-09-02

Use Case: Update a Set of Invoices

A robot must manually update a set of invoices. Explore how data types, triggers, a foreach loop, and expression syntax support this workflow.

Scenario

A robot completes the following tasks for a set of invoices:

  • Identifies an invoice to update in Oracle Cloud ERP.

  • Finds the invoice.

  • Verifies the supplier name and invoice totals, and then updates the invoice.

Workflow

Requirement How to meet the requirement

Define the components of invoice data

Create a data type, InvoiceType, with the following properties:

  • InvoiceNumber
  • InvoiceAmount
  • SupplierName
  • DueAmount

A data type named InvoiceType contains the following properties: InvoiceNumber, InvoiceAmount, SupplierName, and DueAmount.

Tip: To learn more about data types and other placeholder values, see Alternatives to Hard Coding Data.

Define the trigger

Create an input, InvoiceCollection, that is of the InvoiceType data type.

Make the trigger a collection so that it can pass in an array of data--in this case, a number of invoices.

An input named InvoiceCollection is of the InvoiceType data type and is a collection

Define places to store invoice amount and supplier name data

Create the following variables:

  • InvAmt

  • SuppName

Two variables appear: InvAmt and SuppName

Define the navigation to the page in the application where you search for invoices

Using either the recorder or the low-code tools, define the actions that allow the robot to navigate to the area of the application for finding invoices.

After you finish defining the actions, the robot looks something like this:

The canvas contains the following actions: Open Application, Login, Click "Navigator," Click "Payables," Click "Invoices," Click "Tasks," and Click "Manage Invoices"

Create a container for the actions that the robot must perform on every invoice

Add a foreach loop to the robot. The foreach loop defines how the robot iterates over the invoices.

In the foreach loop, use the Collection field to identify the data set that the foreach loop iterates on. Insert the input, InvoiceCollection, into this field.

The Iteration parameter, CurrentInvoice, is the name to use for every record in the collection. This entry becomes a variable that you can reference only in actions within the foreach loop.

The foreach loop is named foreachInvoice. It's Collection value references the input using the following value: ${$INPUT.InvoiceCollection}. The Iteration parameter value references a variable using the following value: CurrentInvoice.

Record the invoice number in the activity stream

Within the foreach loop, create a log action to create an entry in the activity stream for logging the invoice number of every invoice that the robot updates. Knowing the invoice number is helpful if you need to troubleshoot a robot instance.

In the Log action, the following text appears in the Message field: ${$VARIABLE.CurrentInvoice[InvoiceNumber]}

Enter the invoice number into the Search field in the application

Within the foreach loop, use the recorder or low-code tools to enter the value from the InvoiceNumber property of the CurrentInvoice variable into the Search field in Oracle Cloud ERP.

In the recorder, the following text appears in the Value field: ${$VARIABLE.CurrentInvoice[InvoiceNumber]}

Open the invoice

Within the foreach loop, define additional required interactions to open an invoice.

A foreach loop contains the following actions: Log InvoiceNumer, Enter Text, Click "Search," and Click Element

Get the supplier name from an invoice, and save it to a variable

Within the foreach loop, use the recorder or low-code tools to get the supplier name from an invoice and save the value to the SuppName variable.

In the recorder, the Save to value is ${$VARIABLE.SuppName}

Get the invoice total from an invoice, and save it to a variable

Within the foreach loop, use the recorder or low-code tools to collect the invoice total from an invoice.

Save the value to the InvAmt variable.

For the get text action, on the Output tab, the Save to value is ${$VARIABLE.InvAmt}

Take the appropriate action, depending on whether the company name on the invoice matches the company name in Oracle Cloud ERP

Within the foreach loop, create a switch condition that performs the following tasks:

  • Condition 1 determines whether the company names match, and if they do, updates the invoice amount.

    For the switch condition, the Condition value is ${toString($VARIABLE.CurrentInvoice[InvoiceAmount]) == $VARIABLE.InvAmt && $VARIABLE.CurrentInvoice[SupplierName] ==$VARIABLE.SuppName}

    The first condition contains the following expression in the Condition field:

    ${toString($VARIABLE.CurrentInvoice[InvoiceAmount]) == $VARIABLE.InvAmt && $VARIABLE.CurrentInvoice[SupplierName] == $VARIABLE.SuppName}

    In plain English, this condition says the following:

    • Return a string value for the invoice amount that was passed into the robot, and compare the value to the invoice amount that the robot obtained from the invoice.

    • Compare the supplier name that was passed into the robot to the supplier name that the robot obtained from the invoice.

    • If the invoice amounts match AND the supplier names match, update the invoice amount appropriately.

  • Condition 2 specifies that if the company names don't match, do nothing.

On the canvas, the switch condition contains two conditions: Condition 1 and Otherwise.