web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Populate a People comb...
Power Apps
Answered

Populate a People combobox with only certain emails and not the whole organization?

(0) ShareShare
ReportReport
Posted on by 878

Been trying to limit the choices my comboBox has, as now having being created from a Sharepoint list People column, this comboBox has ALL people in the company, when I only need about 4 from a particular branch. The way I see it, there's two options:

1) Manually inserting the emails I need (which can be problematic, if these people leave the company...) But for that I had this code:

Items = [
 {DisplayName: "Nombre de Usuario 1", Claims: "i:0#.f|membership|correo1@dominio.com"},
 {DisplayName: "Nombre de Usuario 2", Claims: "i:0#.f|membership|correo2@dominio.com"},
 {DisplayName: "Nombre de Usuario 3", Claims: "i:0#.f|membership|correo3@dominio.com"}
]

Then on the OnSelect of a button:

YourSharePointList.CreateForm.YourPeopleOrGroupColumn = {
 DisplayName: "Nombre de Usuario 1",
 Claims: "i:0#.f|membership|correo1@dominio.com"
};
YourSharePointList.CreateForm.YourPeopleOrGroupColumn = {
 DisplayName: "Nombre de Usuario 2",
 Claims: "i:0#.f|membership|correo2@dominio.com"
};
YourSharePointList.CreateForm.YourPeopleOrGroupColumn = {
 DisplayName: "Nombre de Usuario 3",
 Claims: "i:0#.f|membership|correo3@dominio.com"
};
SubmitForm(SharePointForm1)

Because if I just did the "SubmitForm(SharepointForm1)", it will not save the selected data. However, this second code gives errors, but I'm guessing it should be something like that. I want to avoid using Patch.

2) The second option would be filtering by the boss of the branch and getting his subordinates. The codes I have so far are:

Office365Users.DirectReports("boss@company.com")
Office365Users.DirectReportsV2("boss@company.com").value

The V2 just produces a blank ComboBox, while the non-V2 does give me the data I need. Problem is, it will NOT save as well into the Sharepoint list.

 

So, do you know the fix for any of my options or a third other that does not involve Patch command? I wondered if this approoach could be acheived by limiting by Office 365 group, as all people I need will be part of this group, but did not know how to filter it this way.

 

Categories:
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @WorkingRicardo ,

     

    In PowerApps, to update SharePoint people columns you need below format for a single person:

     

    {
     Claims: "i:0#.f|membership|" & UserEmail,
     DisplayName: "",
     Email: UserEmail,
     Department: "",
     Picture: "",
     JobTitle: ""
    }

     

     

    Since it seems your person column allows multiple selections, it requires an array and it includes multiple records with the same format. 

    vjefferni_1-1703060914178.png

     

    In Update property of this column Data Card in Edit form, you can use a ForAll function to format the selected results:

     

    ForAll(
     ComboBox.SelectedItems,
     {
     Claims: "i:0#.f|membership|" & ThisRecord.mail,
     DisplayName: ThisRecord.displayName,
     Email: ThisRecord.mail,
     Department: "",
     Picture: "",
     JobTitle: ""
     }
    )

     

     

    Best regards,

  • WorkingRicardo Profile Picture
    878 on at

    @v-jefferni  hey! Thanks for your input. I finally got my code (kind of) to work! This gives me the email of my boss subordinates (2nd tier) , their subordinates (3rd tier) and the entry level employees who are subordinates of those 3rd tiers (so, 4th tier).

     

    ClearCollect(colTeam; UsuariosdeOffice365.DirectReports("BigBosss@company.com"));; 
    ClearCollect(colTeam2; colTeam);;
    ForAll(colTeam; Collect(colTeam2; UsuariosdeOffice365.DirectReports(Mail)));;
    ClearCollect(colTeam; colTeam2);;
    ClearCollect(colTeam2; colTeam);;
    ForAll(colTeam; Collect(colTeam2; UsuariosdeOffice365.DirectReports(Mail)));;
    ClearCollect(colTeam; colTeam2)

    Even though this does what I need, I'm still facing two errors:

    An error message saying: "Error of UsuariosdeOffice365.DirectReports: { "status": 404, "message": "No user was found with the specified id.\r\nclientRequestId: aba6a811-5aed-410e-8a95-1bf3a0848dd3\r\nserviceRequestId: 38889293-f9de-4b33-9c7e-1539e8096c99", "error": { "message": "No user was found with the specified id." }, "source": "office365users-we.azconn-we-002.p.azurewebsites.net" }

     

    However this does not impact that the number of users I need are getting placed in the collection.

     

    The second error is that all of the 3rd tier subordinates are getting doubled in this collection. This also does not impact much on my App, just annoying to have that many results. I tried the Distinct function, but coulnd't get it to work (it would eliminate duplicates but will I could not search for data even if the option was highlighted as possible).

     

    Do you know how I could fix any of the errors?

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @WorkingRicardo ,

     

    You can try below formula first:

    ClearCollect(colTeam; UsuariosdeOffice365.DirectReports("BigBosss@company.com"));; 
    ClearCollect(colTeam2; ForAll(colTeam; UsuariosdeOffice365.DirectReports(Mail)));;
    ClearCollect(colTeam; ForAll(colTeam2;UsuariosdeOffice365.DirectReports(Mail)));;
    ClearCollect(colTeam2; ForAll(colTeam;UsuariosdeOffice365.DirectReports(Mail)));;
    ClearCollect(colTeam; colTeam2)

     

    Also, you can use Distinct function get unique Email addresses from colTeam

    Distinct(colTeam; Mail)

     

    Best regards,

  • WorkingRicardo Profile Picture
    878 on at

    @v-jefferni Hey ty for your reply!

    Just put that code to create the collection, and got this 2 errors on the third line of the code:

    DirectReports has unvalid arguments

    Unvalid name. "Mail" not recognised.

    Tried erasing that line and the combobox only showed [object] [object][object][object][object] once displayed 😞

    DirectReports error.PNG

    Any suggestions? Appreciate the help 😄

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @WorkingRicardo ,

     

    I think now I understand what you would like to achieve. Please try below formula instead:

    ClearCollect(colTeam1; UsuariosdeOffice365.DirectReports("BigBosss@company.com"));; 
    ClearCollect(colTeam2; Ungroup(ForAll(Filter(colTeam1; !IsBlank(Mail)); UsuariosdeOffice365.DirectReports(Mail));"Value"));;
    ClearCollect(colTeam3; Ungroup(ForAll(Filter(colTeam2; !IsBlank(Mail)); UsuariosdeOffice365.DirectReports(Mail));"Value"));;
    ClearCollect(colTeam; colTeam1; colTeam2; colTeam3);

     

    Best regards,

  • WorkingRicardo Profile Picture
    878 on at

    hi again @v-jefferni.

    The code gave errors with that final ";" after the colteam3). I ran it without that ";" and when I start the app through Sharepoint It gives the same error as before:
    "Error de UsuariosdeOffice365.DirectReports: { "status": 404, "message": "No se encontró ningún usuario con el id. especificado.\r\nclientRequestId: 25c8166d-e95d-4b4a-a2b6-5a8cc99ef0d3\r\nserviceRequestId: ab7c860b-e08e-493a-bd98-fb83bd4fd326", "error": { "message": "No se encontró ningún usuario con el id. especificado." }, "source": "office365users-we.azconn-we-002.p.azurewebsites.net" }"

     

    Furthermore, this is not reaching the 4th tier employees. At least the 3rd tiers are not getting duplicated. To illustrate, this is the list of people I need on this collection:

    BigBoss (only one not needed)

    Bosses (2nd tier)

    Line Managers (3rd tiers, the one that with my collection provided code got duplicated)

    Employees (4th tiers)

     

    Let me know what I can do 😞
    Or, if you know of a way that even when you get an error, not make it display it. I could go down the route of my code... Altough dunno what implications this might have in the future.

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @WorkingRicardo ,

     

    The error indicated that an email address in Bosses (2nd tier)/colTeam2 is not found in your organization. How could it happen? 

    vjefferni_0-1703147431450.png

     

    Best regards,

  • WorkingRicardo Profile Picture
    878 on at

    @v-jefferni  Hi!

    Mmm I really have no idea haha 😞
    Because, the 2nd tiers are showing up in the ComboBox, and even the 3rd ones, so the code does have the information of the 2nd ones, otherwise it would not be possible to go down to the 3rd tier.

    Ugh... Maybe this is just impossible to acheive T_T?

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @WorkingRicardo ,

     

    It shouldn't be related to any Controls. As long as all email addresses can be found in your tenant, the formula would work.

    vjefferni_0-1703149881128.png

    My test tenant has only a few users in it (<20), but still the formula works.

     

    Maybe you should try and use UserPrincipalName instead of Mail, in case that there is typo in an Email address of some user's.

    ClearCollect(colTeam1; UsuariosdeOffice365.DirectReports("BigBosss@company.com"));; 
    ClearCollect(colTeam2; Ungroup(ForAll(Filter(colTeam1; !IsBlank(Mail)); UsuariosdeOffice365.DirectReports(UserPrincipalName));"Value"));;
    ClearCollect(colTeam3; Ungroup(ForAll(Filter(colTeam2; !IsBlank(Mail)); UsuariosdeOffice365.DirectReports(UserPrincipalName));"Value"));;
    ClearCollect(colTeam4; Ungroup(ForAll(Filter(colTeam3; !IsBlank(Mail)); UsuariosdeOffice365.DirectReports(UserPrincipalName));"Value"));;
    ClearCollect(colTeam; colTeam2; colTeam3; colTeam4);

     

    Best regards,

  • WorkingRicardo Profile Picture
    878 on at

    @v-jefferni hey again, ty for continued support.

    And yes, the emails can be found in the tenant, as all people are added in the Organization part of the BigBoss,

    The code gave no errors!  And I can see the the 4th tiers even. So, we're close 😄 Problem is, now the 2nd tiers are not on the list. Also, there's a bunch of blank spaces, and there are more blank spaces than the number of 2nd tiers.

    Error.png

     

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard