Note: The above illustrates a desktop test. Using a phone or tablet you would use the camera to capture the receipt.
AI receipt scanning...
Microsoft PowerApps has released a fantastic app to help you submit expense reports. All too often receipts are misplaced. Or quite rightly, more urgent tasks take priority. Assuming receipts are found you may be able to submit them at a later date. If the accounts department allows.
I am not going to show you how to build a receipt processing app. Microsoft has produced an excellent training module click here…
Unfortunately, the training module does not really explain. How to send receipt data from PowerApps to Power Automate (Flow) and then on to your data storage of choice.
This article will show you how to code PowerApp submit button to send receipt data to Power Automate. Then forward the data to One Drive for Business, Excel spreadsheet.
Assuming you are not in the US you might notice currency is in dollars. You can code this to show the currency of your choice. Personally, I do not think it is worth the effort. Excel is the data’s destination and uses spreadsheet functionality this can be easily amended.
So, add a button and name the button text ‘Submit.’
Build the flow
You can either initiate a ‘Power Automate’ from Power Apps, the ‘Action’ menu. Alternatively, open Power Automate in a new browser tab.
On the left click ‘Create’ (1) and along the top, you have options to start from blank. Choose ‘Instant Flow’ (2).
A new window appears. Name your flow. For example ‘Expenses.’ Then click the radio button. On the left choose ‘PowerApps.’ Next click ‘Create.’ You should see the below.
We need to add a ‘Compose’ data operation. Click the ‘New Step’ button.
In the search box type ‘compose.’ Below you should see ‘Compose Data Operations’ click to select.
Place your mouse cursor in the ‘Inputs’ box and on the right sub-menu choose ‘Ask In Power Apps.’
See the beneath.
If you are new to Power Automate. You might be surprised to learn at this stage, we need to ‘Save’ the flow and return to PowerApps. We need to implement this step to be able to generate a JSON scheme.
- Select the button.
- Choose Action from the menu.
- From the ribbon menu select ‘Power Automate.’
- Select the ‘Expenses’ the ‘Power Automate’ you just created.
- Complete the button ‘OnSelect’ code see below
Next, we need to add a receipt. Click the ‘Play’ button and a new window opens.
Click the receipt button(1). You need to have previously scanned a receipt and saved the receipt to wherever you choose. Navigate to the saved scan(2), click to select the scanned receipt, and click open (3).
You should see a circle spinning while it processes the receipt. Once complete you should see your table populated. Click the ‘Submit’ button.
Close the window to return to your app development screen. Assuming all went well you should not see any red circles with white cross.
Return to your ‘Power Automate’ flow and you should see the below ‘Succeeded.’
Complete the flow
Click the title (1 - above) and your Flow will open a new view (see below).
Place your mouse cursor in the ‘Outputs’ (1) box. Hold down the keyboard ‘Ctrl’ key and press ‘A’ to select all. Still holding down the ‘Ctrl’ key press ‘C’ key. Open Notepad or Notepad ++ and place your mouse cursor in the Notepad then press ‘Ctrl’ and ‘P’ keys. You should see something like the one below.
Next you need to edit your flow.
Click the Edit icon top right.
Your next step is to add ‘Parse JSON.’ Click new step and type ‘Parse JSON.’
Expand ‘Parse Json’ to add inputs. Place your mouse cursor in the ‘Content’ (1) box and from the sub-menu on the right and click ‘Outputs’ (2).
Next, we need to generate a ‘Schema’ and click the Generate from sample button (3).
Return to your Notepad and copy the code you pasted earlier. Then click the ‘Done’ button.
Next click ‘+New step’ button and type in the search ‘Apply to Each’ (1) and select (2).
Place your mouse cursor. In the ‘Select an output.' From previous steps (1). Scroll down to the ‘Compose’ section. Select ‘Output’ (2) from the right-hand submenu.
Next click ‘Add an action’ and select ‘Excel Online (Business)’. I am assuming. You have implemented the Get started with receipt processing in AI Builder exercise. If not and you wish to add your receipt data. To ‘One Drive for business – Excel’ then you need to add an Excel workbook (instructions here).
Next, you need to select ‘Excel Online Business’ see above. Then choose ‘Add a row into a table.’
Next for ‘Locations' click the drop-down and choose ‘OneDrive for Business.’
For ‘Document Library’ in the drop-down choose ‘OneDrive.’
‘File’ you need to navigate to where your file is stored.
‘Table’ in the drop-down select your table.
Note: Red asterisk *. You must provide inputs.
When you have added the Excel table you should be asked to add the following.
- Total Price
See the illustration below.
Click the ‘Save’ button.
If you wish, click the ‘Test’ flow. If you are not familiar with test methodology move on to the next step.
Return to ‘PowerApps’ and select ‘Submit’ button. In the ‘OnSelect’ function box add the code below.
Test PowerApp automated workflow using receipt processor
Next test your app.
Click the 'Submit' button.
You should see the below.
Congratulations. Well deserved.
I wish to thank @Mr-Dang-MSFT and @JoeF-MSFT at Microsoft Power Apps community support.
Initially, I was making my solution far too complicated.
Ideally whenever possible in my experience the simpler things are the better.