cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Extracting invoice items from list items with the Power Automate Invoice Processing

Hello forum members,

 

I'm seeking help with a specific task, and I've already followed (successfully) a guide to extract common invoice data. However, what I need help with now is extracting line items and adding them (column by column) to an Excel sheet in Sharepoint.

 

The item list appears to be read correctly, containing 5 items with their respective amounts.

arneulland_0-1690287753010.png

The flow of the process is as follows:

arneulland_1-1690287804060.png

arneulland_2-1690287825499.png

arneulland_3-1690287852902.png


The problem

I'm facing a challenge in getting the specific line items to be added to the Excel sheet properly. The current output either exports all together in one column (if using the line item all columns dynamic array) or doesn't produce the desired result.

 

Goal:
Per new invoice I want the excel sheet to create a new row where the line item amount is imported correctly to the specific column which corresponds with the line item description. If nothing is found then 0 or empty is okey.

It would then look like this (assuming 5 line items)

 

arneulland_1-1690291075904.png

 

 

At the moment, the situation looks like a mess:

Uten navn.png

PS: I have not found a way to manually create dynamic content per header/line item description and I suspect that is the main issue. Said differently, I cannot add line_item_amount per line item description and that is the problem.

arneulland_5-1690288248735.png

 

I would greatly appreciate any guidance or suggestions to help me achieve the desired output. Thank you in advance for your assistance!

18 REPLIES 18
JGT
Helper I
Helper I

One thing I've had to do in the past with data that may be formatted weirdly to get the desired output is converting the data to JSON then using instead of the HTML table to get the variables you are looking for using the Parse JSON function to get the desired output with variables. 

Without knowing exactly what that variable looks like before outputting to the excel file. I'd suggest using Bing Chat to say something like "parse this json data (copy paste the output of the json step) to an excel file. I've had pretty good success with that output being able to parse complex tabled data. 

Anonymous
Not applicable

Interesting. ChatGPT also suggested using variables as a fix:

Step 1: Set up AI Builder in Power Automate (if not done already).

  • Ensure that you have access to AI Builder in your Power Automate subscription.

Step 2: Create a new Power Automate flow.

Step 3: Select a trigger for the flow.

  • Use a trigger that corresponds to the method of importing invoices. For example, you can use the "When an email with an attachment is received" trigger if you receive invoices via email.

Step 4: Add an action to extract invoice data using AI Builder.

  • Add an action using the AI Builder "Extract data from forms" or "Process and save the data" action. This will allow you to extract data from the invoice document.

Step 5: Configure AI Builder action.

  • Select the appropriate model for invoice processing and map the fields you want to extract, such as line item amounts.

Step 6: Initialize a variable to store the extracted line items.

  • Add an action to initialize a variable to store the line items. Use the "Initialize variable" action and set it to an array type.

Step 7: Loop through the extracted data (Apply to each).

  • Since the extracted data may contain multiple line items, use the "Apply to each" action to loop through each line item.

Step 8: Add actions to append line item data to the variable.

  • Within the loop, use actions like "Append to array variable" to add the line item data to the variable. Map the extracted line item amounts to the appropriate column headers in the variable.

Step 9: Add an action to update the SharePoint Excel table.

  • After the loop, use the "Update a row" action in SharePoint to update the Excel table with the line item data stored in the variable. Map the data from the variable to the corresponding columns in the SharePoint Excel table.

Step 10: Complete the flow.

  • After adding all the necessary actions, save and test your flow to ensure that it extracts the line items and updates the SharePoint Excel table correctly.

By following these steps, you should be able to extract line items from the invoice using AI Builder and populate the SharePoint Excel table with the extracted data in an orderly fashion. Make sure to review the actions and adjust the flow based on your specific requirements and the AI Builder model you are using.

Anonymous
Not applicable

Testing with variables now but cannot see how I can create names per variable so that I know which one belongs to which line item.

arneulland_0-1690290533554.png

 

JGT
Helper I
Helper I

The way that is happening you are initializing variables for each item, initialize the variable here

JGT_1-1690299592946.png

then append your array where you are currently initializing it. 

Anonymous
Not applicable

Hi,

What should I choose in this instance to give the variable a value that fits (there is no way to connect to the line items and specify which amount I want to set the variable as)

arneulland_0-1690306611269.png

 

Anonymous
Not applicable

The above refers to the fact that I cannot find a way to set a variable to "each item" as there is no way to distinguish the items. 

 

The dynamic array just state "line item amount (text)".

JGT
Helper I
Helper I

You will initialize the variable like you are doing, add the items in the loop like you had it before to "add those items" then call that variable later. So for example the order would be:
1. Create the variable
2. add all the items to the variable
3. do any formatting you need to on the variable you added items to
4. use the variable

Anonymous
Not applicable

Unfortunatly cannot follow your suggestion.
1) I do the following to create the variable (the apply to each comes automatically when using line item)

Skjermbilde 2023-07-25 203649.png

 2) When trying to use the variable again  it's impossible

Skjermbilde 2023-07-25 203838.png
Also tried to save but get the following error: Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable_2' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each_3'.'.

JGT
Helper I
Helper I

Here I show you 🙂 I created an example array "data" with the  [red,green,blue] in an earlier step. Then initialized a blank array, incremented the new blank array in a loop FOR all the items in "data" and sent a teams message to myself of the current item in the array its LOOPING through. 

JGT_1-1690311265582.png

The teams messages I got looks like this:

JGT_2-1690311374155.png


Does that make more sense? The value of the array named "Add Data to me" would be [red,green,blue] now as well.

JGT
Helper I
Helper I

Also to note, in your example where you need to do some formatting to "sanitize" the data before inputting it to an excel file. You will want to do the formatting before you add the variable to the append array variable. If you don't want to use an "Array" and instead would use an "object", you can hand it json data which seems in my experience to be handled better by Power Automate. 

Anonymous
Not applicable

Appreciate the help. Slowly getting to a solution it seems : ) I followed the steps but when saving I get the error:

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Add_a_row_into_a_table' at line '1 and column '11412' is invalid. Action 'Apply_to_each_2' must be a parent 'foreach' scope of action 'Add_a_row_into_a_table' to be referenced by 'repeatItems' or 'items' functions.'.'.

Am I missing something here?

1.png

2.png



Anonymous
Not applicable

Also tried to apply to each items in the last section but that didn't change anything

 

3.png

Anonymous
Not applicable

Okey, saw an error that I did and appended the variable within the apply to each together with the Add a row into a table.
 

5.png

Now this doesn't really solve the issue because the output looks like this.

The goal was to get the output mapped out in one row for the right column and not 5 rows per line item. 

6.png

So I'm still struggling with the basic issue
- How to get the line items mapped into the right column when I add an excel row

Anonymous
Not applicable

Like this. If no line item is found with the right name then skip (invoices can have different fields so only want the items to be aligned with the text)

77.png

Anonymous
Not applicable

Please note that I have no problem getting the spesific line items per row as shown below.


It's about that I only want 1 row with the numbers aligned per column

33.png

Anonymous
Not applicable

Output comes as this if I set every variable equal to line item amount, which is not very helpful
Anonymous
Not applicable

 
Anonymous
Not applicable

Update: Decided that it was too difficult to get the line items in one row so created this simple solution instead.

 

One day I need to learn how to extract the specific amount per line item but this will do. 

Thanks for the help!

123.png

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,015)