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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / ForAll() not working???
Power Apps
Answered

ForAll() not working???

(0) ShareShare
ReportReport
Posted on by 79

Hi,

 

I have a gallery and a button (outside the gallery).

 

The formula of the button is below: it just updates the existing records

ForAll(
QuoteProductGallery.AllItems,
{
Quantity: 3,
Quote: GUID(QuoteIdGuidLabel.Text)
}
)

 

Any help is appreciated.

 

Thanks!

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @marvinbarnuevo 

    What is your goal here?

  • bebeben10 Profile Picture
    79 on at
    I am trying to update items in the gallery using button outside the gallery.
  • mdevaney Profile Picture
    29,989 Moderator on at

    @marvinbarnuevo 

    I have a way to do this but first can you please share the code used in the Items property of your Gallery?

  • bebeben10 Profile Picture
    79 on at

    @mdevaney 

     

    Items in the gallery (gallery 2) are coming from collection (colQuoteProducts) which are being populated by another gallery (gallery 1).

     

    Below is the expression of the button from gallery 1:

    Patch(
    'Quote Products',
    Defaults('Quote Products'),
    {
    quoteid: LookUp(
    Quotes,
    quoteid = GUID(QuoteIdGuidLabel.Text)
    ),
    quantity: 1,
    quotedetailname: ThisItem.Product.Name,
    'Existing Product': LookUp(
    Products,
    Product = ThisItem.Product.Product
    ),
    Unit: LookUp(
    Units,
    uomid = ThisItem.Unit.Unit
    ), producttypecode: LookUp(
    'Quote Products',
    'Existing Product'.Product = ThisItem.Product.Product,
    'Product type'
    ),
    propertyconfigurationstatus: LookUp(
    'Quote Products',
    'Existing Product'.Product = ThisItem.Product.Product,
    'Property Configuration'
    )
    }
    );
    ClearCollect(
    colQuoteProducts,
    Filter(
    'Quote Products',
    Quote.Quote = GUID(QuoteIdGuidLabel.Text)
    )
    );
    ClearCollect(
    colQuoteProductsGroupBy,
    GroupBy(
    colQuoteProducts,
    "parentbundleid",
    "flem_byparentproduct"
    )
    );
    ClearCollect(
    colQuoteProductsGroupBySum,
    AddColumns(
    colQuoteProductsGroupBy,
    "Total Amount Sub Prod",
    Sum(
    flem_byparentproduct,
    'Sub Amount'
    ),
    "Total Unit Gross",
    Sum(
    flem_byparentproduct,
    Amount
    ),
    "Total Cost",
    Sum(
    flem_byparentproduct,
    Cost
    )
    )
    );
    ForAll(
    QuoteProductGallery.AllItems,
    {
    Quantity: Value(QtyTextInput.Text),
    Duty: Value(DutyTextInput.Text),
    'Supplier Discount': Value(DiscountTextInput.Text),
    'Add Discount': Value(AddDiscountTextInput.Text),
    FRT: Value(FRTTextInput.Text),
    Other: Value(OtherTextInput.Text),
    Margin: Value(MarginTextInput.Text),
    'FX Rate': Value(FXRateTextInput.Text),
    Cost: Value(CostLabel_1.Text),
    quoteid: LookUp(
    Quotes,
    quoteid = GUID(QuoteIdGuidLabel.Text)
    ),
    'Quote Product': GUID(QuoteProductIdLabel.Text),
    'Supplier Cost Price': Value(PricePerUnitLabel.Text),
    'Sub Amount': Value(TotalAmountLabel.Text)
    }
    );

  • mdevaney Profile Picture
    29,989 Moderator on at

    @marvinbarnuevo 

    You question caused me to realize an entire column could have its value changed with a single line of code... noice!

    UpdateIf(colQuoteProducts,true,{Quantity:3, Quote: GUID(QuoteIdGuidLabel.Text)})

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • bebeben10 Profile Picture
    79 on at

    @mdevaney 

     

    My apologies. I think I am being vague here.

     

    To make it simpler and precise:

    1. I have a gallery (gallery 1)

    2. The items from the gallery is coming from a collection (collection 1)

    3. I have a button outside the gallery. The expression of the button is below:

     

    ForAll(QuoteProductGallery.AllItems, Patch('Quote Products', {Quantity: 3}))

     

    What I would like to achieve here is to save all the items in the gallery 1 to the 'Quote Products' data source using the button.

     

    Hope this helps..

     

  • mdevaney Profile Picture
    29,989 Moderator on at

    @marvinbarnuevo 

    Simpler and more precise is always good!  I was confused by having so much code.

     

    My general solution is to put code that looks like this in the button.  I have added additional fields called SomeField1, SomeField2 in case you'd like to add more info from the gallery.  You should replace these with your real field names.

    ClearCollect(myCollection, QuoteProductGallery.AllItems)
    ForAll(
     myCollection,
     Patch(
     'Quote Products',
     Defaults('Quote Products'),
     {
     SomeField1: myCollection[@SomeField1],
     SomeField2: myCollection[@SomeField2],
     Quantity: 3
     }
     )
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • bebeben10 Profile Picture
    79 on at

    @mdevaney 

     

    That's almost the same expression I have. Interestingly, it is not working.

    powerapps_error.png

     

    If my expression is like this:

    ForAll(QuoteProductGallery.AllItems, {Quantity: 3})

     

    It doesn't have any error but not really working.

  • mdevaney Profile Picture
    29,989 Moderator on at

    @marvinbarnuevo 

    Well, one difference is your PATCH is missing an argument.  PATCH requires 3 arguments but you only have 2 arguments.  The 2nd argument Defaults('Quote Products') tells PowerApps to create a new record.

    Patch('Quote Products',Defaults('Quote Products'),{Quantity: 3})

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • bebeben10 Profile Picture
    79 on at

    @mdevaney 

     

    PATCH also accepts 2 arguments - it means you are updating specific record. But regardless if I put 2 or 3 arguments in the PATCH, PowerApps always throw an error.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard