cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gjayne84
Frequent Visitor

Populating people picker based on choice field

Hi everyone

I am trying to find a way of automatically populating a people picker field in a PowerApps SharePoint form based on the value of a separate choice field.  I have an approval form and want users to be able to choose from a small list of approvers without having to search for them.  However, I've tried using a people picker with a person field on the SharePoint list that points to an approvers SharePoint group but this won't allow users to display all people in this group.

My solution to this would be to create a choice field with the 6 names of approvers.  I want the approver people picker field to then automaticaly populate with the user that is chosen from the choice field but can't get this to work.  The people picker field is expecting a record type and the choice field can only provide text values.

Is this possible?

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

HI @gjayne84,

Do you want to populate the Person field within your Edit form automatically based on the selected approver name within the Choice field?

I have made a test on my side, please take a try with the following workaround:1.JPG

 

2.JPG

Firstly, you need to add a Office 365 Users connection within your app.

Within the Edit form (SharePointForm1), set the DefaultSelectedItems property of the Combo Box control within the ApproverPersonField Data card to following:

If(
    SharePointForm1.Mode=FormMode.New,
    {
      Claims: "i:0#.f|membership|" & Lower(LookUp(Office365Users.SearchUser(),DisplayName = DataCardValue3.Selected.Value,Mail)),
      DisplayName: DataCardValue3.Selected.Value,
      Email: LookUp(Office365Users.SearchUser(),DisplayName = DataCardValue3.Selected.Value,Mail),
      Department:"",
      JobTitle:"",
      Picture: ""
    },
    Parent.Default
)

Note: The DataCardValue3 represents the Combo Box control within the ApproverChoiceField Data card.

On your side, you shoukld type:

If(
    SharePointForm1.Mode=FormMode.New,
    {
      Claims: "i:0#.f|membership|" & Lower(LookUp(Office365Users.SearchUser(),DisplayName = YourApproverChoiceComboBox.Selected.Value,Mail)),
      DisplayName: DataCardValue3.Selected.Value,
      Email: LookUp(Office365Users.SearchUser(),DisplayName = YourApproverChoiceComboBox.Selected.Value,Mail),
      Department:"",
      JobTitle:"",
      Picture: ""
    },
    Parent.Default
)

Please check the attached GIF screenshot for more details:

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Mr-Dang-MSFT
Power Apps
Power Apps

Hi @gjayne84,

It sounds like you want to have a SharePoint list that has a Person/Group column for selecting multiple people. But rather than showing all possible people, you only want it to show the people who are valid approvers.

 

Here's how I would set up a Person column in a combobox in a form:

 

Single-select Person column 
Items: Choices(ListName.ColumnName)
DefaultSelectedItems: Parent.ColumnName

 

Multi-select Person column shown in a combobox inside a gallery
Items: Choices(ListName.ColumnName)
DefaultSelectedItems: Parent.ColumnName

 

Parent.ColumnName would show the value that has been saved.

 

If the approvers would not change, I would suggest collecting each of them to a collection.

Hi @Mr-Dang-MSFT

Thanks for the swift response.  I only need to select a single approver but my setup is shown below:

Fields.PNG

The choice field is a normal choice field with text values:

Choice field.PNG

In the above example, if I clicked John Doe in the normal choice field it should then automatically populate the people picker field with John Doe.  Ideally I would prefer to just have the people picker field behave in the same way as the choice field where the list of approvers appears without having to search for them by name, but I understand this isn't currently possible in PowerApps.

@gjayne84,

Can you clarify why you need two different columns for approvers? I am not following.

 

What is the difference between the two columns?

@Mr-Dang-MSFT

The ApproverChoiceField is a normal choice column:

ApproverChoiceField.PNG

The ApproverPersonField is a Person or Group column:

ApproverPersonField.PNG

As people in our company may not know the names of the approvers they need to be able to pick from a list rather than having to search for them by name.  Ideally I don't want to have the two columns but having a choice field with the approvers names, which then populates the actual people picker field seemed like the only way of achieving this?  I've tried linking the person or group column to a SharePoint group that only contains the approvers but the PowerApps people picker control still requires the user to type in a name to show them.

v-xida-msft
Community Support
Community Support

HI @gjayne84,

Do you want to populate the Person field within your Edit form automatically based on the selected approver name within the Choice field?

I have made a test on my side, please take a try with the following workaround:1.JPG

 

2.JPG

Firstly, you need to add a Office 365 Users connection within your app.

Within the Edit form (SharePointForm1), set the DefaultSelectedItems property of the Combo Box control within the ApproverPersonField Data card to following:

If(
    SharePointForm1.Mode=FormMode.New,
    {
      Claims: "i:0#.f|membership|" & Lower(LookUp(Office365Users.SearchUser(),DisplayName = DataCardValue3.Selected.Value,Mail)),
      DisplayName: DataCardValue3.Selected.Value,
      Email: LookUp(Office365Users.SearchUser(),DisplayName = DataCardValue3.Selected.Value,Mail),
      Department:"",
      JobTitle:"",
      Picture: ""
    },
    Parent.Default
)

Note: The DataCardValue3 represents the Combo Box control within the ApproverChoiceField Data card.

On your side, you shoukld type:

If(
    SharePointForm1.Mode=FormMode.New,
    {
      Claims: "i:0#.f|membership|" & Lower(LookUp(Office365Users.SearchUser(),DisplayName = YourApproverChoiceComboBox.Selected.Value,Mail)),
      DisplayName: DataCardValue3.Selected.Value,
      Email: LookUp(Office365Users.SearchUser(),DisplayName = YourApproverChoiceComboBox.Selected.Value,Mail),
      Department:"",
      JobTitle:"",
      Picture: ""
    },
    Parent.Default
)

Please check the attached GIF screenshot for more details:

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

How would I go about about populating the people picker filed automaticaly from a SharePoint list based on Lookup action?


Depending on the Contract Type I select, the People picker should populate the Purchace Manager name  handing that contract Type

I can get a lable populated with the correct Purchace manager using the formula below
LookUp('Contract Types', ContractType=fld_Contract_Type.Selected.Value).Purchasing_x0020_Manager.Email

How would I used that to populate a peple's picker field.?

Anonymous
Not applicable

Hi @gjayne84  @Mr-Dang-MSFT 

I am suffering from the same issue. People Picker fields that connect to a SharePoint group (to fetch some users as an approver not all AD users) in PowerApps doesn't show as a dropdown. Although it show the control as dropdown but won't allow user to open that dropdown. Instead, It only allows users to search by typing the name which would be an issue once users don't know the name of those approvers.

Have you found a solution/workaround for that?

How we can tell PowerApps to show list of those values as a real dropdown that user can choose from?05.PNG

Great, this was exactly what I was looking for. Just a note, that search didn't work for me, so the code I needed to Adjust was more like:

Screen.OnVisible:

Set(gvCurrentUser, Office365Users.MyProfileV2())

 

Action modified search

If(
Form1.Mode=FormMode.New,
{
Claims: "i:0#.f|membership|" & Lower(First(Office365Users.SearchUser({searchTerm: gvCurrentUser.displayName})).Mail),
DisplayName: gvCurrentUser.displayName,
Email: First(Office365Users.SearchUser({searchTerm: gvCurrentUser.displayName})).Mail,
Department:"",
JobTitle:"",
Picture: ""
},
Parent.Default
)

 

Regards,

Dennis

I am using your example to do something similar.  My scenario is that I have a dropdown from a 2nd list that populates text fields (a user being one of those fields), but since it is a text field and not a person field, I would also like to update my person field with the same value that is in the text field.  On the screen it populates it as it should but when I try to save I get an error message saying:

"The requested operation is invalid.  Server Response:  ListA failed:  The specified user i:0#.f|membership| could not be found.  Client RequestID:......."

 

UPDATE:  I am not getting BadGateway

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (3,569)