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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / ForAll (Collect()) Syn...
Power Apps
Answered

ForAll (Collect()) Syntax Problem

(0) ShareShare
ReportReport
Posted on by 64

Hello,

 

I'm struggling with the following code:

 

ForAll(invoices,Collect(invWorkOrders,Filter('[dbo].[WorkOrder]',InvoiceID=ID)));

 

The steps:

 

1) Collect the invoices related to the current billing cycle

2) For each invoice, collect all of the WorkOrders based on the WorkOrder.InvoiceID = invoices.ID.

 

I cannot figure out how to get the syntax to work in order to reference the invoices.ID of the current loop iteration in the ForAll. I've seen something like [@ID] before, but I can't find any record of that on the forum.

 

How do I reference the current record values in invoices in the above example?

Categories:
I have the same question (0)
  • Christopher S Profile Picture
    Microsoft Employee on at

    Hi @ocdc2008 ,

     

    Can you please share with me the exact error message that you are receiving?

     

    Best Regards

  • ocdc2008 Profile Picture
    64 on at

    Hello,

     

    I am not receiving an error message. The syntax seems to be valid, but I'm thinking the formula is confused as to what which :ID I am attempting to reference.

     

    My guess is it thinks I am trying to say pull records when ['dbo'].['WorkOrder'].InvoiceID = ['dbo'].['WorkOrder'].ID as opposed to what I want: ['dbo'].['WorkOrder'].InvoiceID = ThisInvoiceFromTheLoop.ID

  • Verified answer
    WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @ocdc2008 ,

    A bit of a guess here, but try the below - I am suspecting '[dbo].[WorkOrder]' also has an ID and there is some Ambiguity. There is nothing wrong with your code syntax.

    ForAll(
     RenameColumns(
     invoices,
     "ID",
     "ID1"
     ),
     Collect(
     invWorkOrders,
     Filter(
     '[dbo].[WorkOrder]',
     InvoiceID=ID1
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • ocdc2008 Profile Picture
    64 on at

    @WarrenBelz 

     

    This worked! It seems like a bit of a work around when there should be built in syntax for specificity, but this will do!

     

    Thank you.

  • WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @ocdc2008 ,

    Yes there is disambiguation syntax available, but when coming from a collection, renaming is always reliable.

  • ocdc2008 Profile Picture
    64 on at

    @WarrenBelz Thanks for providing both options. Very helpful.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard