cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Update field if other field matches - delegation limit

Using SharePoint list as DataSource. To find those records where Area="Area 1" and change them all to be "Area 2", the code below works fine except that it is subject to the delegation limitation in the ForAll function.

 

Is there a way to perform this same simple operation but find matching records anywhere in the dataset? For example, if there were two matches, the first was record number 1 and the second match was number 10,000 I would want to update both of these.

 

Works but only up to the limit for non-delegated queries

 

Collect(colFind,
    Filter(DataSource, Area="Area 1")
);

ForAll(colFind,Patch(DataSource,
   LookUp(DataSource, ID = colFind[@ID]),
   {Area:"Area 2"}
   )
)

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Update field if other field matches - delegation limit

Both functions (the collect function and the patch function) are non-delegable functions. So the you have to do the sorting in both. I dot know if you have another purpose for the collection. Otherwise you could get the items and patch them in one step instead of first collecting and then patching.

View solution in original post

6 REPLIES 6
Highlighted

Re: Update field if other field matches - delegation limit

If the number of items that match the comparison Area="Area 1" is below 500 (or 2000 if you use the preview upgraded data limit) you can look into sorting the data source you collect in the collect function Collect(colFind,Filter(Sort(Datasouce,Area, ascending),Area="Area 1")) in such a way that all the items are within the 500-2000 items of the sorted data source.
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Update field if other field matches - delegation limit

Thanks @Rebetcha

 

I thought this would work but I didn't get the results I expected but maybe I'm missing something.

 

In my list, I modified 5 records to so Area= "Area 1" so these are the last 5 modified records. With the app settings item limit set to 2, I tested the code below and was expecting 2 records to be collected and 2 to be patched. Instead 2 records were collected but nothing was patched. Evidently I have something wrong on the second part now...

 

Collect(colFind,
Filter(Sort(DataSource,Modified, Descending),Area="Area 1"));

ForAll(colFind,Patch(DataSource,
   LookUp(DataSource, ID = colFind[@ID]),
   {Area:"Area 2"}
   )
)
Highlighted

Re: Update field if other field matches - delegation limit

Both functions (the collect function and the patch function) are non-delegable functions. So the you have to do the sorting in both. I dot know if you have another purpose for the collection. Otherwise you could get the items and patch them in one step instead of first collecting and then patching.

View solution in original post

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Update field if other field matches - delegation limit

I see what you mean, that makes sense actually.

 

I used this and it worked! Thanks for pointing that out.

 

Collect(colFind,
Filter(Sort(DataSource,Modified, Descending),Area="Area 1"));

ForAll(colFind,Patch(DataSource,
   LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID]),
   {Area:"Area 2"}
   )
)
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Update field if other field matches - delegation limit

Somewhat of a related question. would it be also possible to patch a value from a column in the collection to a column in the matched records? What is shown below does not seem to work. 

 

Collect(colFind,
Filter(Sort(DataSource,Modified, Descending),Area="Area 1"));

ForAll(colFind,Patch(DataSource,
   LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID]),
   {Area:colFind.Title}
   )
)

 

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Update field if other field matches - delegation limit

I think I figured it out in case anyone else is following. Thanks @Rebetcha for helping point me in the right direction 🙂

 

This patches the plaintext value from colFind Area into the corresponding field in the DataSource for the matching record.

 

Collect(colFind,
Filter(Sort(DataSource,Modified, Descending),ID = 761));

ForAll(colFind,
Patch(DataSource,
   LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID]),
   {Area:LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID],Area )}
   )
)

And this patches the lookup column ID to a plain number field.

 

Collect(colFind,
Filter(Sort(DataSource,Modified, Descending),ID = 761));

ForAll(colFind,
Patch(DataSource,
   LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID]),
   {AlignmentID:LookUp(Sort(DataSource,Modified, Descending),ID = colFind[@ID],Alignment_x003a_ID.Id )}
   )
)

 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,052)