.st0{fill:#FFFFFF;}

MS PowerApps – Solve business problems with receipt processing 

 September 2, 2020

By  Christopher Bird

Receipt expense reporting

Note: The above illustrates desktop test. Using a phone or tablet you would use the camera to capture receipt. 

AI receipt scanning...

Microsoft PowerApps has released a fantastic app to help you submit expenses 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 allow. 

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. 

Scan receipt

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. Given Excel is the data’s destination and using 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, ‘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).

MS Flow

A new window appears. Name your flow. For example ‘Expenses’ then click the radio button on the left to choose ‘PowerApps.’ Then click ‘Create.’ You should see the below.

Flow Wizard
Flow

We need to add a ‘Compose’ data operation. Click the ‘New Step’ button.

Flow

In the search box type ‘compose.’ Below you should see ‘Compose Data Operations’ click to select.

Flow

Place your mouse cursor in the ‘Inputs’ box and on the right sub menu choose ‘Ask In Power Apps.’

Flow

You should see the below.

Flow

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.

Submit
  1. Select the button.
  2. Choose Action from the menu.
  3. From the ribbon menu select ‘Power Automate.’
  4. Select the ‘Expenses’ the ‘Power Automate’ you just created.
  5. Complete the button ‘OnSelect’ code see below
Set(test, JSON(ReceiptProcessor1.PurchasedItems)); Expenses.Run(test)
Power App OnSelect

Next, we need to add a receipt. Click the ‘Play’ button and a new window opens.  

Receipt scanner

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).

Steps to add receipt

You should see a circle spinning while it processes the receipt. Once complete you should see your table populated. Click the ‘Submit’ button.

AI identifies receipt data
Receipt data capture

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.’

Data sent from Power Apps

Congratulations.

Complete the flow

Click the title (1 - above) and you Flow will open a new view (see below).

JSON scheme

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 below.

Power Automate Output

Next you need to edit your flow.

Click the Edit icon top right.

Edit Flow

Your next step is to add ‘Parse JSON.’ Click new step and type ‘Parse JSON.’

Power Automate New Step
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 ‘Schema’ click the Generate from sample button (3).

Parse JSON select Outputs
Add copied Compose Output

Return to your Notepad and copy the code you pasted earlier. Then click the ‘Done’ button.

MS Power Automate generate JSON
JSON scheme created.

Next click ‘+New step’ button and type in the search ‘Apply to Each’ (1) and select (2).

Apply to each

Place your mouse cursor in the ‘Select an output from previous steps’ (1) and scroll down to ‘Compose’ section and select ‘Output’ (2) from the right-hand submenu.

Parse JSON output

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 a Excel workbook (instructions here).

Excel Online Business

Next you need to select ‘Excel Online Business’ see above. Then choose ‘Add a row into a table.’

Excel Online

Next for ‘Locations' click the drop down and choose ‘OneDrive for Business.’

For ‘Document Library’ in the drop down choose ‘OneDrive.’

For ‘File’ you need to navigate to where your file is stored.

For ‘Table’ in the drop down select your table.

Note: Red asterisk *. You must provide inputs.

Specify data posting
Flow Add file

When you have added the Excel table you should be asked to add the following.

  1. Name
  2. Price
  3. Quantity
  4. Total Price

See the illustration below.

Excel online table
Data columns for Excel

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.

Power App On Select code
Expenses.Run(JSON(ReceiptProcessor1.PurchasedItems)) Next test your app. You should see the below.

Test PowerApp automated workflow using receipt processor

Next test your app.

Click the 'Submit' button. 

You should see the below.

Excel Online Business

Congratulations. Well deserved. 

Acknowledgements

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.

MS PowerApps - Solve business problems with receipt processing PDF 


__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"62516":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"62516":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]},"original":{"colors":{"62516":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"ee969":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"ee969":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]},"original":{"colors":{"ee969":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
Previous Article
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"ee969":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"ee969":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]},"original":{"colors":{"ee969":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
Next Article

Christopher Bird


Building your own Power App, BI solution, or automated workflow can be a mind-blowing experience. It can also be a nightmare. Particularly when you begin with a blank screen. My advice, get professional help as and when you need it. That's what successful people do.

Christopher Bird

related posts:



{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

>