Invoice Automation using the Power Platform
Invoice processing is something that every company does, but many are still doing it manually and is very labor intensive. Not anymore! I'll show you how to use the new "Process and save information from invoices" flow in Power Automate to automatically capture invoice information, save it to a SharePoint document library. We’ll then use Cognitive Services to extract the invoice line-item information and save it to a SharePoint List. Finally, Power Apps will allow you to review and complete the processing so it can be integrated with the accounting LOB application.
Process Overview
Invoices come in several different ways. Ideally, they would be electronic, if not most scanners/copiers have integration into SharePoint that makes the capture process easy to accomplish. Here is a typical process overview for most organizations.
SharePoint Schema
To get things started, we need to configure out content types and SharePoint information architecture to accommodate capturing the invoice “header” information, typically located at the top that has non-repeating items such as vendor name, invoice number, date due etc.
We also need a “line items” list to hold each itemized item that has been purchased. A typical schema should resemble this:
A few things to keep in mind:
Automate metadata extraction using Power Automate
Now that we have the plumbing in place to receive the information, time to configure the tools for the metadata extraction.
Power Automate has a new activity, “Process and save information from invoices” that we’ll use to automatically extract the invoice header information. This couldn’t be much easier! I’ve set a few variables that we’ll use later in the flow but simply pass the file contents and it will scan and return values that can be used to update the Invoices metadata.
Once OCRed, the results are automatically available to be mapped to the document library.
Line-Item Extraction using Cognitive Services
Getting the line-item information requires a little more work but Azure Cognitive Services does the hard part for us.
Configure Form Recognizer in Azure
The ability to OCR a document and have AI determine if there is a table in the document is accomplished using the Form Recognizer service in Azure. You’ll need to configure this so we can use it in Power Automate.
3. Once created there are a few things you’ll need to use the service:
a. Get the Endpoint – we’ll use this in Power Automate to pass our invoice to the service.
b. Get at least 1 of the Keys. We’ll also need this to call the service.
Send the invoice to Cognitive Services
Extracting the line-item information (table) from the document requires 2 calls to the Forms Recognition service:
NOTE: The HTTP header must contain the Ocp-Apim-Subscription-Key key and the value is the key from the Forms Recognizer service we created in Azure. The URI is the Endpoint that was created plus the method to analyze the document.
NOTE: The key needs to be in the HTTP Header again. The URI is like the 1st call but contains the URI is decorated with the RequestID output from the 1st call.
Parse the JSON body
Using Visual Studio Code and a JSON plugin, you can analyze the JSON output. Key areas to focus on are:
Row 1, Column 1 (0 based array) in the table…IE invoice lines.
Updating the Line-Item list
Taking the JSON response from the Azure function we can now iterate through the rows updating the SharePoint list with the results. Notice a couple things:
PowerApps for Accounting Review
Phew…the hard part is done! The user interface that accounting will use is done in PowerApps.
Form features include:
Searching for invoices
Users can review the status of any invoice input into SharePoint using the search.