Skip to main content
Community site session details

Community site session details

Session Id : 3UAZKKMnHvQukEjjdzDBq/
Power Apps - Building Power Apps
Answered

Patching Dataverse within ForAll as specified by a Collection

Like (0) ShareShare
ReportReport
Posted on 8 Dec 2023 14:37:14 by

Hi all,

I'm having trouble with a Patch operation from within PowerApps and I hoped someone here could help me.

I have a collection (MyCollection) with a column containing an ID (CollectionID).
Using a ForAll loop, I'm trying to Patch a choice column ('My Parameter') in each record of a Dataverse Table(MyDataverseTable), where the column 'Dataverse ID' is equal to the CollectionID of the current item being iterated in MyCollection.

So, if the CollectionID of the current record is 1234, it should patch the 'My Parameter' column of the record with the 'Dataverse ID' of 1234.

I've tried permutations of things like:

ForAll(
	MyCollection,
	Patch(MyDataverseTable,
		LookUp(MyDataverseTable,
		'Dataverse ID' = Text( MyCollection[@Collection_ID] )
		),
	{'My Parameter':'My Parameter (MyDataverseTable)'.Yes}
	)
);

 

It seems however, that the CollectionID of the Collection record is not accessible inside the LookUp.
The code does not throw an error, it simply seems to do nothing.

What am I doing wrong here?

Thanks for any input!

  • R_March Profile Picture
    on 11 Dec 2023 at 08:05:00
    Re: Patching Dataverse within ForAll as specified by a Collection

    Hi all,

    Thanks for your suggestions. They both work, I took the first one for simplicity. However, what was also making things not work was the "Text(MyCollection.Collection_ID)" part of the formula, as it was not being delegated. As a workaround I added an extra column to my collection with the same ID in Text format, did the comparison then and now it works fine. Thanks once more!

  • Ethan_009 Profile Picture
    4,838 Moderator on 09 Dec 2023 at 12:59:06
    Re: Patching Dataverse within ForAll as specified by a Collection

    Hi @R_March ,

     

    Try the following code

    ForAll(
     MyCollection,
     With(
     {
     CurrentRecord: LookUp(MyDataverseTable,
     'Dataverse ID' = Text( ThisRecord[@Collection_ID] )
     )
     },
     Patch(
     MyDataverseTable,
     CurrentRecord,
     {
     'My Parameter':'My Parameter (MyDataverseTable)'.Yes
     }
     )
     )
    );

     

    Hope this helps

  • Verified answer
    scalca Profile Picture
    on 09 Dec 2023 at 08:53:17
    Re: Patching Dataverse within ForAll as specified by a Collection

    what you can do is to add the As function into ForAll
    so for example, ForAll(MyCollection As CollectionRecord, Patch(DataverseTable, LookUp(DataverseTable, Id = Text(CollectionRecord.Id))

    the choice value must match value in your Dataverse Table where you can references directly the dataverse column in order to get the choice values

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473