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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set dropdown default v...
Power Apps
Unanswered

Set dropdown default value to a value from users list

(0) ShareShare
ReportReport
Posted on by 54

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!

I have the same question (0)
  • v-bofeng-msft Profile Picture
    on at

    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 control’s 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

  • GilbertS Profile Picture
    54 on at

    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!

  • v-bofeng-msft Profile Picture
    on at

    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

  • GilbertS Profile Picture
    54 on at

    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.

  • v-bofeng-msft Profile Picture
    on at

    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

  • Verified answer
    GilbertS Profile Picture
    54 on at

    I managed it differently!

     

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

     

    Thanks for your help!

  • myvsparth Profile Picture
    31 on at

    try this

    If(!IsBlank(Parent.Default),Parent.Default,LookUp(Users,'Primary Email'=User().Email))

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard