cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerUser19
Helper III
Helper III

Have default Display Name in people picker

Hello, I am trying to get default display name in the people picker based on the other field. In my scenario, based on the Visiting Area chosen in a combo box, I would like to set specific Manager Name. This is only to show the default person in the people picker. If the user needs to change, the user should be able to remove the default person and select a different person by searching. 

 

May I please know how to achieve this? Attaching the image. 

I tried the below code. It comes up with an error If( "ABCD" in VisitingAreaDataCardValue12.SelectedItems, DataCardValue16.Value="Firstname Lastname", Parent.Default )

4 REPLIES 4

@PowerUser19 

 

You don't do this in Power Apps:

 

//don't do this to try to set DataCardValue16.Value
DataCardValue16.Value="Firstname Lastname"
//don't try to set DataCardValue16.Value directly in a formula.
//the only reason to say 
//DataCardValue16.Value="Firstname Lastname" 
//is if you want to check if DataCardValue16.Value is equal to "Firstname Lastname" - but this will not set the value of the data card.

 

You do not set the "Property.Value" directly in Power Apps using an equal sign.

= means "check if the left side is equal to the right side" - it never sets anything.

 

Whenever you want to say Something.Value = "Something else" to set a value of something - remember not to do that in Power Apps - you only do that if you want to compare if Something.Value is equal to "Something else".

You should approach this another way in Power Apps.

 

"Control.Value" of something can be accessed from elsewhere, but it is not to be "set" directly in the way you are attempting, in Power Apps.

 

To achieve what you want where something has a default value,

 

just use the Default property of the control.

For example, Drop down control has a Default property which could be used for this purpose.

Drop down control key properties - docs.microsoft.com

 

When the Default property is used, suppose on a Drop down control called Dropdown1 - if the user does not change anything in Dropdown1, then Dropdown1.Selected.Value - when accessed from elsewhere, should match what's in the Default property of Dropdown1.

 

For a Combo box control, it would be DefaultSelectedItems

Key properties of Combo box controls - docs.microsoft.com

 

Check if it helps @PowerUser19 

PowerUser19
Helper III
Helper III

@poweractivate  Thank you for letting me know! Is it possible to guide how to achieve this using Default property? I actually had my code in the original post written in the Default property but I understand it is incorrect.

@PowerUser19 

 

First, try to not use DataCardValue16.Value="Firstname Lastname" anywhere in the formula, I told you to make sure not to use it in my initial post, as attempting to use SomeControl.Value = "Some String" tells Power Apps to compare SomeControl.Value with "Some String"  - it does not tell Power Apps to change SomeControl.Value.

Instead, just use "Firstname Lastname" and use it in the Default property of the Control, like the following :

 

//use this in Default property of the Control
If( "ABCD" in VisitingAreaDataCardValue12.SelectedItems, "Firstname Lastname", Parent.Default )

 

If the above doesn't work, 
try each of these for Default property, and see which one gives the error first:

"Firstname Lastname"

 

Parent.Default

 

VisitingAreaDataCardValue12.SelectedItems

 

"ABCD" in VisitingAreaDataCardValue12.SelectedItems
//should put "true" or "false" as the default value

 

For whichever of the above gives the error, correct it, and then correct it in the If function.

 

If this still does not work and no error is shown with any of the above, let me know if you could provide more details on the specific error that is shown. Also, if you see an error with the above, but are unsure how to correct it based on what the error says, provide the details of the error as well.

PowerUser19
Helper III
Helper III

Hi @poweractivate ,

Thanks for the response. Please excuse my ignorance here. I am learning while I build this app.

I get "Invalid Argument Type (Record) Expected Text Value instead" error message.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

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.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,707)