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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / ComboBox prepopulate u...
Power Apps
Answered

ComboBox prepopulate user() and patch

(0) ShareShare
ReportReport
Posted on by 219

I have read a new of posts and I'm struggling with something...
Like many other suggestions I'm declaring a varUser on app start to = User()
I have a combo box labeled "CmbRequestor"

selectMultiple: false

isSearchable: true

items: Office365Users.SearchUser({searchTerm: CmbRequestor.SearchText})
defaultSelectedItems: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: Concatenate(
"i:0#.f|membership|",
Lower(varUser.Email)
),
Department: "",
DisplayName: varUser.FullName,
Email: varUser.Email,
JobTitle: "",
Picture: ""
}

The form will display the users display name in the combobox. Brilliant....
I give them the capability to change it if they want and if they do change it - it will work.

BUT if they submit it without changing it (showing the default value) it fails and here's why....the Requestor in the patch statement is expecting my values to all be stored in the comboBox variable...that variable as mentioned above is called CmbRequestor.

Patch(
 'Ticket Request',
 Defaults('Ticket Request'),
 {Title: "Request"},
 {
 Requestor: {
 '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
 Claims: Concatenate("i:0#.f|membership|",Lower(CmbRequestor.Selected.Mail)),
 Department: "",
 DisplayName: CmbRequestor.Selected.DisplayName,
 Email: CmbRequestor.Selected.Mail,
 JobTitle: "",
 Picture: ""
 }
 } etc... 

But it doesn't recognize the CmbRequestor to have a mail value... ONLY a displayname. So what's happening is because I don't search it absolutely requires my defaultSelectedItems to be correct...why is it not recognizing the email address??? Below you can see the DisplayName populated... but the Email is not showing up???

Not the value of the ExecutiveVP below is what it should look like for claims and email. So I think I know what I'm doing but something is not registering for me here why that default isn't sufficient to be stored under the defaultSelectedItems.


sasrsc1966_0-1636757451232.png

 

As  a bonus for those smart people: why is it that I have to populate the default value in the defaultSelectedItems  and not simply Default? Multiple is set to false.

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,080 Most Valuable Professional on at

    Hi @sasrsc1966 ,

    I must admit I stay away from people fields (just get it with the O365Users connector and store it in Text), but the below may work on your Items (you did not say how you formed the Variable.

    With(
     {
     wUser:
     If(
     IsBlank(CmbRequestor.SearchText),
     varUser().Email,
     CmbRequestor.SearchText
     )
     },
     Office365Users.SearchUser(
     {searchTerm: wUser}
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

  • sasrsc1966 Profile Picture
    219 on at

    In the end I took your advice and did this.
    In my case I do need to keep the column a special "person" column in SP.

    So for the defaultSelectedItems I did...

     

    thisUser

     

    For them items I did...(where the combo box is named CmbRequestor)

     

    Office365Users.SearchUser({searchTerm: CmbRequestor.SearchText})

     

     Then the key was as you say... I set a variable to thisUser creating the person complex field. This could have been done in numerous places. I happen to do it on a gallery at the onSelect action which then populates the form.

     

    Set(thisUser,{
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: Concatenate(
     "i:0#.f|membership|",
     Lower(varUser.Email)
     ),
     Department: "",
     DisplayName: varUser.FullName, 
     Email: varUser.Email,
     JobTitle: "",
     Picture: ""
    })

     

    For the actual "insert statement"....I took your advice and did...

    /* insert into list */
    With(
     {
     wUser: If(
     IsBlank(CmbRequestor.Selected.Mail),
     varUser.Email,
     CmbRequestor.Selected.Mail
     )
     },
     If(
     IsEmpty(
     Errors(
     'Ticket Request',
     Patch(
     'Ticket Request',
     Defaults('Ticket Request'),
     {Title: "Request"},
     {
     Requestor: {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: Concatenate(
     "i:0#.f|membership|",
     Lower(wUser)
     ),
     Department: "",
     DisplayName: CmbRequestor.Selected.DisplayName,
     Email: wUser,
     JobTitle: "",
     Picture: ""
     }
     },
     {'Seats Requested': Value(InpHowManyTickets.Text)},
     {'Parking Pass Requested': Value(InpHowManyPP.Text)},
     {'Customer Request': DrpIsCustomer.Selected.store},
     {Comments: InpRequestComments.Text},
     {EventId: requestEventID},
     {TicketStatusId: 1}/* = pending */
     )
     )
     ),
     /* display message */
     Notify(
     "Your tickets have been requested.",
     NotificationType.Success
     ),
     /* if unsuccessful notify */
     Notify(
     "There is an error with your request!",
     NotificationType.Error
     )
     )
    );



     Thank you as always.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 339 Most Valuable Professional

#2
11manish Profile Picture

11manish 180

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard