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

Set dropdown default value to a value from users list

Can someone help me please?

 

I have a entity on which I store knowledge levels of our users. Therefore I created a lookup from the users table in my knowledge level entity, called mdw_id.

Now I am creating a PowerApp in which the users can add knowledge by themselves. I got it all working if they must select their own user id out of the created dropdown list. However I don't want them to select their own user id, I want this stored (on the background) by default to the current logged in user. The User() is working, because I have it somewhere on that same page. But it is not working for that mdw_id field.

 

On the "newLanguage" form I have now 3 fields. The mdw_id which is a lookup field in Users, the language which is a lookup field in the Language entity and a knowledge level. As said it is working like this. But I want the mdw_id filled by default.

If I select the user via the dropdown, it is shown and stored as "Lastname, Firstname".

 

I set up the DataCardValue of the DataCard mdw_id like:

DefaultSelectedItems:

If( NewLanguage.Mode = FormMode.New;
{ Value : User().fullname };
Parent.Default )

 

In the formula editor box I see User().fullname = Firstname Lastname. And if I run the app it is also shown the value FirstName Lastname. However it is giving also an error saying that value should be an entity item.

 

If I change the { Value : User().fullname } to { Value : "Lastname, Firstname" } it is showing the same error.

 

I have tried to set the { Value : First(Filter(Users; domainname = User().Email)) } but that is not giving any result. I guess it has to do with the First statement is giving a full User entity. I guess it must know which field out of this entity should be taken.

 

Can someone provide me with the correct solution?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Set dropdown default value to a value from users list

I managed it differently!

 

I have now the defaultSelectedItems: First(Filter(Users; domainname = varUser.Email))

 

Thanks for your help!

View solution in original post

6 REPLIES 6
Highlighted
Community Support
Community Support

Re: Set dropdown default value to a value from users list

Hi GilbertS:

Do you want to automatically fill in the record of the current user that in the user entity into the dropdown control?

Could you tell me whether you use combo box control or drop down control?

 

Case1: combo box(I recommend this solution )

You can achieve it through setting the DefaultSelectedItems property of the combo box control.

Set the drop down controls DefaultSelectedItems property to:

 

LookUp(Choices('knowledge levels'. mdw_id),User().FullName in 'Full Name') 

 

/*Since user () function can only call full name, for convenience, I used "Full name" directly. In addition Full Name is a field that already exists in users entity, so you can use it directly*/

 

b.png

 

Case2: drop down

Set the dropdown control’s default property to:

 

LookUp(Choices('knowledge levels'.crec3_mdw_id),User().FullName in ' Full Name’).'Full Name'  

 

 

 

 

Best Regards,

Bof

Highlighted
Frequent Visitor

Re: Set dropdown default value to a value from users list

Hi v-bofeng-msft,

 

I used indeed a combo-box. I have set the DefaultSelectedItems to what you stated. However that was not giving any result. But I read somewhere that using Email address is more stable. Therefore I changed the User().Fullname to User().Email.

 

If I look at the formula screen I can see the correct record is selected. However on the screen it is not selected and it is not stored in the CommonDataService.

 
 
 

PowerAppCombobox.JPG

 

On the screen I see no selected item:

PowerAppComboboxLeeg.JPG PowerAppComboboxLijst.JPG

In the table it is storing without Mdw_id:

PowerAppComboboxEntiteit.JPG

Please @v-bofeng-msft suggest what to fix. Thanks!

Highlighted
Community Support
Community Support

Re: Set dropdown default value to a value from users list

HI @GilbertS :

I suggest you try this code:

LookUp(Choices(tbltalen.cr438_Mdw_id),User().Email in 'Primair e-mailadres') 

with out using "[@XX]"

Best Regards,

Bof

Highlighted
Frequent Visitor

Re: Set dropdown default value to a value from users list

That doesn't help. It is worse. Now the formula has an error. It is saying: "Function choices has illegal arguments." "The name is not valid. This id is not recognized.

 

PowerAppComboboxFout.JPG

The first formula was correct I guess. But somehow it is not selecting.

Highlighted
Community Support
Community Support

Re: Set dropdown default value to a value from users list

Hi @GilbertS :

May be misspelled.I see the drop-down box has popped up the data source name.Try to choose the option that pops up in the drop-down box.

Best Regards,

Bof

Highlighted
Frequent Visitor

Re: Set dropdown default value to a value from users list

I managed it differently!

 

I have now the defaultSelectedItems: First(Filter(Users; domainname = varUser.Email))

 

Thanks for your help!

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (6,258)