Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

ForAll Patch not Patching Data

(0) ShareShare
ReportReport
Posted on by 762
Hello Community,
I need your help please, I have tried to find the answer but I'm struggling with this one.

I have a Gallery that shows multiple items, as I'm trying to build an Requisitions Application. and I have a GL Code Which is a Combo box, I've added a label for testing to show the values, but when I try to patch the data, it does not update each item I selected and also it updates another item in the SharePoint list that was not selected, as was already had the Approval Status as Approved for testing purpose.


This is the Button OnSelect property - I know I have the delegation warning, but just can't get this to work as expected.
I have tried to change the GLChoice Field to ddGLChoice.Selected.Value, I've tried using a Label in the patch with Text.



Running out of Idea's so really hoping someone can help me.
Thank you!
Claire


 
Categories:
  • Suggested answer
    ClaireAllen Profile Picture
    ClaireAllen 762 on at
    ForAll Patch not Patching Data
    Thank you Community for your help and responses, I have managed to find a solution that works with Power Automate and Power Apps

    This is how I managed to get it working.
     
    ClearCollect(
        colFilteredItems,
        ForAll(
            Filter(
                GallCCOrderItems.AllItems,
                !IsBlank(ddGLChoice.Selected.Value)
            ),
            {
                OrderID: Text(ThisRecord.OrderID), // Ensure OrderID is treated as text
                GLChoice: ThisRecord.ddGLChoice.Selected, // Store the selected GLChoice
                RowID: ThisRecord.ID // Store the selected GLChoice
            }
        )
    );
    
    // Step 2: Trigger the flow to update SharePoint list
    ForAll(
        colFilteredItems As item,
        Notify("Patching OrderID: " & Text(item.OrderID) & " with GLChoice: " & item.GLChoice.Value, NotificationType.Information);
        
        'HM-PRCCUpdateGLChoiceAndApproval'.Run(
            Text(item.GLChoice.Value), // Pass the selected GLChoice value
            Text(item.OrderID), // Pass the selected OrderID
            Text(item.RowID) // Pass the selected OrderID
        )
    );
     
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,940 on at
    ForAll Patch not Patching Data
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee
  • WarrenBelz Profile Picture
    WarrenBelz 144,940 on at
    ForAll Patch not Patching Data
    Try using the As identifier - also possibly some overkill here, but it should work.
    With(
       {
          _Items:
          AddColumns(
             Filter(
                CCOrderItems,
                OrderID = Text(ddRequisitionID.Selected.ID) 
             ),
             OrderTxt,
             Text(OrderID)
          )
       },   
       ForAll(
          _Items As _I,
          Patch(
             CCOrderItems,
             LookUp(
                CCOrderItems, 
                OrderID = _I.OrderTxt
             ),
             {
                GLChoice: {Value: _I.ddGLChoice.Selected.Value}
             }
          )
       )
    );
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps   
    Buy me a coffee
  • ClaireAllen Profile Picture
    ClaireAllen 762 on at
    ForAll Patch not Patching Data
    timl, the error with the line is just a delegation warning, but thank you for the info.

    @Artur Stepniak, I'm not sure that the collection is working correctly as the GL Code always looks empty to me, but I will certainly double check that - thank you!

    @Pacel1, thank you for the information, I will take a look at what you have suggested.

     
  • Pacel1 Profile Picture
    Pacel1 79 on at
    ForAll Patch not Patching Data
    I assume you want to update all elements for which you select a value in the GLcode field?
    If so, the logic should look like this:
     
    ClearCollect(
        colilteredItems, 
        ForAll(
            Filter(
                Gallery1.AllItems,
                !IsBlank(ddGLChoice.Selected.Value)
            ),
            { OrderID: ThisRecord.ID, 			// Here You have to put field with ID number from Your source
    		  GlChoice: ThisRecord.ddGLChoice.Selected.Value	
    		}
        )
    )
    
    
    
    ForAll(
    	colFilteredItems, 
    	Patch(
    		CCOrderItems,
    		LookUp(CCOrderItems, OrderID = ThisRecord.OrderID),
    		{
    		GLChoice: ThisRecord.GlChoice
    		}
    )
    )
    
    
     
  • timl Profile Picture
    timl 33,168 on at
    ForAll Patch not Patching Data
    Hi Claire,
     
    I notice that in step 2 of your screenshot, '= (ThisRecord.OrderID)' is underlined in red.
     
    This is the most likely cause of this issue. If you resolve the error that's given when you hover the mouse over that line, that will hopefully solve the problem. 
  • Artur Stepniak Profile Picture
    Artur Stepniak 1,252 on at
    ForAll Patch not Patching Data
    Hello,
     
    are you sure that the filtered collection contains the values that you'd like to update? I'd suggest you should check first after filtering if the variable is correctly updated.
     
    Let me know how it goes.
     
    Best regards,
     
    Artur Stepniak

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

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,940

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,523

Leaderboard