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 / Getting data from coll...
Power Apps
Answered

Getting data from collection row in forall

(1) ShareShare
ReportReport
Posted on by 260

I need some help solving this and thank you all in advance.

 

I have a collection that is bulit from user actions which has several columns:

 

  • Image
  • Image Title
  • File Name
  • File Path

the first three are created each time a Collect() is done.  The FilePath gets created by running a Power Automate that is the returned value.  The problem I am trying to solve is how, inside a ForAll(), I can use each File name value to pass as a parameter to the Power Apps run. command.

 

Here's what I am trying to do:

 

ForAll(Sequence(CountRows(colItems)),
Patch(colItems, Index(colItems, ThisRecord.Value),
{FilePath: SignaturePhoto.Run(<colItems.FileName>).FilePath })
);

 

I tried using ThisRecord.FileName but it doesn't work.  So how do I specify the column value from the record in coItems being processed>  This proably will be so obvious once someone responds.

Categories:
I have the same question (0)
  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    Not sure why you use ForAll on Sequence?
    Try like this:

    ForAll(colItems,
     Patch(colItems, ThisRecord,
     {FilePath: SignaturePhoto.Run(ThisRecord.FileName).FilePath})
    );
    
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @lmheimendinger 

    Furthermore we should use Patch outside ForAll for better performing and easier to maintain formula, here's how:

     

    To reduce the overhead of patching inside a ForAll loop and instead collect the changes and patch them all at once, this can be achieved as follows:

    Step 1: Create Collections for Base Records and Changes

    First, you should create two collections, one for the base records and another for the changes. You can use the ForAll function along with ClearCollect for this purpose.

    For the base records:

    ClearCollect(colBaseRecs, colItems);
    

    For the changes:

    ClearCollect(colChangeRecs,
     ForAll(colItems,
     {
     ID: ThisRecord.ID,
     FilePath: SignaturePhoto.Run(ThisRecord.FileName).FilePath
     })
    );
    

    Step 2: Use the Patch Function with Collections

    Next, you can use the three-argument version of Patch to apply the changes. This version takes the data source (in this case, your original collection), base records, and changes as arguments:

    Patch(colItems, colBaseRecs, colChangeRecs);

    See if this helps as well @lmheimendinger 

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

     

    @lmheimendinger 
    I don't recommend it (I recommend use my Patch outside ForAll way with the Collections instead), but if you really want to keep your original formula Patch inside ForAll, you may need to disambiguate ThisRecord like the following:

     

    With({wColItems: colItems},
     ForAll(wColItems,
     Patch(colItems, wColItems[@ThisRecord],
     {FilePath: SignaturePhoto.Run(ThisRecord.FileName).FilePath})
     )
    );
    

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @lmheimendinger 
    One more thing, for your scenario to work correctly, Power Apps should await for the Flow to complete.

    To make sure this happens, you must have at least one "Respond to a Power App or Flow" block in the Flow.
    poweractivate_4-1691771810432.png

    You also have to have one for there to be a return value to be used by FilePath in your Canvas App, and actually, also make sure to return an appropriate FilePath from the Flow for it to work correctly for your scenario.

  • lmheimendinger Profile Picture
    260 on at

    That appears to be workable as the expression works.  Thanks

  • lmheimendinger Profile Picture
    260 on at

    Going with the simplier solution but thank you.

  • lmheimendinger Profile Picture
    260 on at

    I forgot that I switched to Seququence() because you can't patch a record in the collection used by ForAll().

     

    Back to the drawing board.

  • Verified answer
    lmheimendinger Profile Picture
    260 on at

    Here's what did work.

     

    When I did Collect() to add an item to the collection, I also did a Collect() to a duplicate collection.  When the collection is complete, I then do this:

     

    ForAll(colDuplicate,
    Patch(colItems, ThisRecord,
    {FilePath: "https://<stuff>" & <flowname>>.Run(varAction, ThisRecord.FileName,ThisRecord.,columnname>).varpath}
    )
    );

    The flow returns the file path when it saves the item into a SharePoint library.  colDuplicate is an exact copy of colItems so I use the ForAll on it but Patch the correspondind record in colItems. 

     

    I appreciate the helpful suggestions which got me to the right place.

     

     

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard