cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mamacona
Helper I
Helper I

Delegation Warning, LookUp more than 2000 Users

Hello

I am trying to build an app that gets the Office 365 Users Profiles and Write them in a Sharepoint List, however the Manager field must be a LookUp field getting the managers from the same List. In order to do this I was thinking to run the app twice, first to get all the users and then to identify the managers and write the lookup field.

I was already helped by @RandyHayes here but I am blocked in something:

 

Screenshot 2022-03-30 at 09.34.24.png

 

This delegation warning, I think I will have problems was the users can be more than 2000.

 

 

 

Patch(Org,
    ForAll(Filter(Office365Users.SearchUserV2().value, AccountEnabled=true),
        With({_rec: LookUp(Org, MailColumn = Mail)},
            {
                ID: _rec.ID,
                Title: DisplayName,
                MailColumn: Mail,
                JobTitleColumn: JobTitle,
                DepartmentColumn: Department,
                Manager: With(LookUp(Org, MailColumn = Office365Users.Manager(Id).Mail), {Id: ID, Value: Title}) 
                
                
            }
        )
    )

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Mamacona ,

No - you will not get more than 2,000 items at once either in a collection of using With().

View solution in original post

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @Mamacona ,

I cannot test this (so you may also get a warning here), but try

With(
   {
      wUsers:
      Filter(
         Office365Users.SearchUserV2().value, 
         AccountEnabled
      )
   },
   Patch(
      Org,
      ForAll(
         wUsers As aPatch,
         { 
            ID: aPatch._rec.ID,
            Title: aPatch.DisplayName,
            MailColumn: aPatch.Mail,
            JobTitleColumn: aPatch.JobTitle,
            DepartmentColumn: aPatch.Department,
            Manager: 
            {
               With(
                  {
                     wMan:
                     LookUp(
                        Org, 
                        MailColumn = Office365Users.Manager(Id).Mail
                     ), 
                     {
                        Id: wMan.ID, 
                        Value: wMan.Title
                     }
                  ) 
               )
            }
         }
      )
   )
)

 

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

Mamacona
Helper I
Helper I

Thanks for your answer @WarrenBelz , I see I have an error from the aList

Screenshot 2022-03-30 at 15.05.47.png

@Mamacona ,

Typo (now fixed) - the problem with free-typing code . . . try now

@WarrenBelz 

Thank you! I have still this weird error

 

Screenshot 2022-04-01 at 17.30.19.png

 

thank you again and again!

@Mamacona ,

What is _rec.ID ? I was simply using your values, which I assumed were valid.

Mamacona
Helper I
Helper I

@WarrenBelz  Yes they are

Look here

 

With({_rec: LookUp(Org, MailColumn = Mail)},

 

It was mentioned there to read the store the ID.

What i am trying to do is a button that when i press it, gets all the users with some attributes from Office 365 Users and writes this into a SharePoint List. At the same time this writes a Lookup as Manager, this manager is taken from the same List. The problem is that, there are more than 2000 values and it is too much for it 😞

Hi @Mamacona 

I missed that bit at the top

With(
   {
      wUsers:
      Filter(
         Office365Users.SearchUserV2().value, 
         AccountEnabled
      ),
      _recID: 
      LookUp(
         Org, 
         MailColumn = Mail
      ).ID
   },
   Patch(
      Org,
      ForAll(
         wUsers As aPatch,
         { 
            ID: _recID,
            Title: aPatch.DisplayName,
            MailColumn: aPatch.Mail,
            JobTitleColumn: aPatch.JobTitle,
            DepartmentColumn: aPatch.Department,
            Manager: 
            {
               With(
                  {
                     wMan:
                     LookUp(
                        Org, 
                        MailColumn = Office365Users.Manager(Id).Mail
                     ), 
                     {
                        Id: wMan.ID, 
                        Value: wMan.Title
                     }
                  } 
               )
            }
         }
      )
   )
)

however, whatever you do here, you will be limited to 2,000 records in the output of the top statement (or however else you try to collect the users).

 

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

Mamacona
Helper I
Helper I

@WarrenBelz 

Thank you! but actually I was looking for a way to overcome this limitation  :(, there is a way to do it?

Hi @Mamacona ,

No - you will not get more than 2,000 items at once either in a collection of using With().

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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