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 / How to set default val...
Power Apps
Unanswered

How to set default value for combo box with user name

(0) ShareShare
ReportReport
Posted on by 265

Hi guys,

 

How to give default value to a ComboBox with current user name ?

I tried to put in property Default or DefaultSelectedItem but returned error. I'm using User().Fullname

 

In Items property I already have this : Office365Users.SearchUser({searchTerm:MyComboBoxName.SearchText}), this is so that when we type in my combo box, it is automatically filter the list. But I need to be filled in by current user name at first.

 

I found this thread : https://powerusers.microsoft.com/t5/Building-Power-Apps/Default-value-of-combo-box/m-p/298441#M85966

but to me it is hard to understand why ?

 

Thanks,

 

 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @Voltes 

    You should be able to just copy and paste this code into the DefaultSelectedItems property of your ComboBox and have it work.

     

    If(Form1.Mode=FormMode.New,
     { 
     DisplayName:User().FullName,
     Claims:"i:0#.f|membership|" & Lower(User().Email), 
     Department:"", 
     Email:User().Email, 
     JobTitle:"", 
     Picture:""
     },
     ThisItem.YOURFIELDNAME
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Voltes Profile Picture
    265 on at

    Hi @mdevaney 

     

    Yes, it works. Much appreciated if you can tell me just a little, what is the meaning of that code ?

    I've put the 1st line only actually, since I thought I only need the name in that box. Will that make the code invalid or missed its purpose ? 

     

    So, it is like this:

    Voltes_0-1603284713006.png

    Thanks again.

    V

     

     

  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at

    @Voltes 
    Yes of course.  This is the most important section of my code.

    { 
     DisplayName:User().FullName,
     Claims:"i:0#.f|membership|" & Lower(User().Email), 
     Department:"", 
     Email:User().Email, 
     JobTitle:"", 
     Picture:""
    }

     
    A person field in SharePoint is known as a complex column type.  This means it stores more than one piece of data about a person.  In fact it stores several! 

    • DisplayName: Office 365 display name
    • Claims: a unique identifier that represents a specific user
    • Email: the user's email etc.
    • Picture: Office 365 user photo
    • etc, etc, etc.


    So when we want to display a person in a new Power Apps form we must build the person object from scratch.  That's why we need all of that code inside the { } brackets. 

     

    I would suggest you copy my code entirely.  At the very least you must have these fields: Claims, DisplayName, Email.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Voltes Profile Picture
    265 on at

    Hi @mdevaney ,

     

    Many thanks for the explanation. It really help me to understand more on this.

     

    Thanks.

  • Community Power Platform Member Profile Picture
    on at

    You are the cat @mdevaney ! Your blog is super good too man! Thank you for all the work you put in to bring out the best in this toolset.

  • Golly Profile Picture
    127 on at

    Just an FYI that square brackets are needed in this code in addition to the curly ones (at least for me).

    If(Form1.Mode=FormMode.New,
     [{
     DisplayName:User().FullName,
     Claims:"i:0#.f|membership|" & Lower(User().Email), Department:"",
     Email:User().Email,
     JobTitle:"", Picture:""
     }],
    [ThisItem.YOURFIELDNAME]
    )

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