cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gochix
Resolver I
Resolver I

ForAll Patch more than 2000 rows??

Hi,

I have a collection that contains more than 6000 rows of data. I store all info using clearcollect.

Question: How to ForAll Patch exceeding 2000 rows? 

Thought if it's possible to read more than 2000 rows using this formula :

ClearCollect(StoresList,Filter(CatalogueList,PartID <= 2000),Filter(CatalogueList,PartID >2000 && PartID <=4000),Filter(CatalogueList,PartID >4000 && PartID <=6000),Filter(CatalogueList,PartID >6000 && PartID <=8000));

 Then maybe it's also possible to somehow patch over 2000 rows?

 

Thanks in advance.

13 REPLIES 13
BCLS776
Super User
Super User

The code I shared above will create a new entry in the database table each time it runs -- the Defaults(TestUpdate) argument takes care of that. If you need code that updates existing records or creates new ones, try this:

ForAll(UpdateList As aRecord,
    With({aLookup: LookUp(TestUpdate, Title = aRecord.Title),
        If(IsBlank(aLookup),
            Patch(TestUpdate, Defaults(TestUpdate),
            {
                Title: aRecord.Title,  
                Description: aRecord.Description, 
                Quantity: Value(aRecord.Quantity) 
            }
            ),
            Patch(TestUpdate, aLookup,
            {
                Quantity: Value(aRecord.Quantity) 
            } // If a record exists, update the quantity only
            )
        )
    )
);

Note, you will need to clear your table or remove the duplicate records first.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

Gochix_0-1632514749908.png

Invalid numbers of arguments, received 3, expected 2. I thought that one of } is still open but can't figure out where.

Oops, my mistake (I was free typing). It is missing a "}" on the aLookup record

 

ForAll(UpdateList As aRecord,
    With({aLookup: LookUp(TestUpdate, Title = aRecord.Title)},
        If(IsBlank(aLookup),
            Patch(TestUpdate, Defaults(TestUpdate),
            {
                Title: aRecord.Title,  
                Description: aRecord.Description, 
                Quantity: Value(aRecord.Quantity) 
            }
            ),
            Patch(TestUpdate, aLookup,
            {
                Quantity: Value(aRecord.Quantity) 
            } // If a record exists, update the quantity only
            )
        )
    )
);

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks, I was about to reply that i found a typo mistake.

This finally works. 

Thank you so much for your efforts. You literally saved me as i was desperate that my app was almost finished but i couldn't get an update feature ready..

Thanks and enjoy your evening/night 😉

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,943)