web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Selecting records from...
Power Apps
Unanswered

Selecting records from a SharePoint list

(0) ShareShare
ReportReport
Posted on by 10

Hello experts,

I'm building an app using the Expense Report template https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/expense-report-install

The app requires two SharePoint lists, one for the main report and a second list for line items. ReportID is a foreign key in the Line Items list. 

The issue I'm having is pulling the details of each line item in my approval Flow. I would like for the Expense Approver to see a breakdown of each line item before they approve it. This means pulling records from the LineItems SP list but Flow won't let me pull them. It fails to save and complains about a loop in a loop. Screenshot below:

 

The template validation failed: 'The inputs of template action 'Condition' at line '1 and column '2345' cannot reference action 'Start_and_wait_for_an_approval'. The action 'Start_and_wait_for_an_approval' is nested in a foreach scope of multiple levels. Referencing repetition actions from outside the scope is supported only when there are no multiple levels of nesting.'.
 
Any pointers on how to achieve my goal? I need the Cost and Description to show in the body of the approval email. 

 

Categories:
I have the same question (0)
  • notj Profile Picture
    782 on at
    Re: Selecting records from a SharePoint list

    The problem is in the condition at the bottom of your screenshots. Can you show what you have in there? Something you're evaluating is the issue.

  • jhd2020 Profile Picture
    10 on at
    Re: Selecting records from a SharePoint list

    Thanks for the response @notj . Here is what is in there. Not much changed from the original template

     

    conditons.png

  • notj Profile Picture
    782 on at
    Re: Selecting records from a SharePoint list

    In your "After" picture, it adds a loop automatically because you're referencing an array, not a single value. Hover over the value in the that Apply to Each 4 and it will show you that you're not referencing a single value, but a returned array of them.

  • jhd2020 Profile Picture
    10 on at
    Re: Selecting records from a SharePoint list

    @notj that makes sense. The line items could be multiple. So what is the best way you recommend to handle this? Sorry I'm a newbie at this. 

  • notj Profile Picture
    782 on at
    Re: Selecting records from a SharePoint list

    From the wording on the approval message. I don't think adding description and cost there are what you want. If either of those are coming from the value of LINE ITEMS and not the single EXPENSE ITEM, you would just have a list of results. Your email would look like:
    Please review and take action below.

    Description: bike tire, bike, replacement handlebars, speed pedals(which you're probably fine with)

    Cost: 24, 400, 100, 70(which is not that helpful)

     

    I think you should initialize 2 variables at the top of your flow under the trigger. One is an array titled "LineItemDescriptions", and another is a number titled "LineItemSum".

     

    After getting your line items, do a loop on the returned items. Use action "Append to Array" to add each description to the variable. The other you can do a Set Variable action, reference itself + the current item cost. Then in your approval, you reference these variables instead of the values.

  • jhd2020 Profile Picture
    10 on at
    Re: Selecting records from a SharePoint list

    Thanks @notj . I will give that a try today. 

  • jhd2020 Profile Picture
    10 on at
    Re: Selecting records from a SharePoint list

    Hello @notj ,

    Thanks to you I'm getting closer but not there yet. So i added two new variables as you recommended and was able to get the sum and items in my approval but formatting is off.  It lists the items on the same line rather than Item/Cost per line. 

     

    2020-01-23 13_03_54-Mail - Ope Adejumobi - Outlook.png

     

     

    I also tried the array method but the LineItemArray doesn't show as a dynamic value I could pick from in my approval email. 

     

    Any thoughts? I've attached the screenshot of the flow

  • notj Profile Picture
    782 on at
    Re: Selecting records from a SharePoint list

    Ah, I misunderstood. So you want to display it in a table-like design. In the loop where you're storing your values into variables, do a "create html table" instead. Then throw the output of the html table in your email.

  • jhd2020 Profile Picture
    10 on at
    Re: Selecting records from a SharePoint list

    @notj 

    Added table. It seems the approvals action require markdown language for formatting. 

     

    2020-01-23 14_06_19-Mail - Ope Adejumobi - Outlook.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard