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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,051)