Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

DefaultSelectedItem using Office365Users not patching correctly to SharePoint List People column

(0) ShareShare
ReportReport
Posted on by 22
Hi all.
 
In brief, I am trying to patch a record to a SharePoint List with multiple columns. One of the columns is a People column.
 
I use the Office365Users connector.
 
I have a form with a combo box for 'User', with items fed by the Office365Users connector. If I manually select the user from the combo dropdown, this patches correctly to the SharePoint List along with other info.
 
When I try to set a default for the combo box for the current user, this does not patch anything to the People column in the SharePoint List unless I manually change the entry.
 
Below are the details
 
Combo box Items:
 
Filter(
    Office365Users.SearchUser({searchTerm: cboUser.SearchText}),
    AccountEnabled = true && Not("#EXT#" in UserPrincipalName)
)
 
Combo box DefaultSelectedItems:
 
CurrentUser
 
 
UpdateContext({    
    CurrentUser: {    
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",    
        Claims: "i:0#.f|membership|" & Lower(User().Email),    
        Department: "",    
        DisplayName: User().FullName,    
        Email: User().Email,    
        JobTitle: ".",    
        Picture: "."    
    }    
})
 
Patching code extract, where cboUser is the relevant combo box:
 
Patch(
    InnovationPortal_Ideas,
    Defaults(InnovationPortal_Ideas),
    {
        Title: txtTitle.Text,
        Short_description: txtShortDesc.Text,
        Long_description: txtLongDesc.Text,
        Status: cboStatus.Selected,
        Submitted_date: dateSubmitted.SelectedDate,
        User:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpanderUser",
            Claims: cboUser.Selected.Mail,
            Department: "",
            DisplayName: cboUser.Selected.DisplayName,
            Email: cboUser.Selected.Mail,
            JobTitle: " ",
            Picture: " "
        },
        Category: cboCategory.SelectedItems,
        IsNew: true
    }
);
 
The default itself appears correctly in the combo box, but it's clearly not correctly set as it doesn't match what the SharePoint List column needs fed to it when patching, whereas manually reselecting the same name does work fine.
 
I'm guessing this is because the 'currentuser' context variable is pulling from the Power Apps current user using User() and this doesn't necessarily match up with the Office365 Users despite seeing the same data and columns. If that's the case, I'd appreciate a suggestion for a better way of pulling the current user details in a way that matches the Office365Users connector and the People column in the SharePoint List.
 
Any help much appreciated!
Categories:
  • newbieappdeveloper Profile Picture
    22 on at
    DefaultSelectedItem using Office365Users not patching correctly to SharePoint List People column
    You're an absolute star! Thank you!
  • Verified answer
    WarrenBelz Profile Picture
    146,660 Most Valuable Professional on at
    DefaultSelectedItem using Office365Users not patching correctly to SharePoint List People column
    You sort of almost had it right if you combined the correct bits from the two pieces of code. Your Items of
    Filter(
       Office365Users.SearchUser({searchTerm: Self.SearchText}),
       AccountEnabled && Not("#EXT#" in UserPrincipalName)
    )
    will output a slightly different schema with Mail instead of Email, so your Variable for the DefaultSelectedItems (why are you bothering with the Variable ?)
    UpdateContext(
       {    
          CurrentUser: 
          {    
             Claims: "i:0#.f|membership|" & Lower(User().Email),    
             Department: "",    
             DisplayName: User().FullName,    
             Mail: User().Email,    
             JobTitle: ".",    
             Picture: "."    
          }    
       }
    )
    and your Patch
    Patch(
       InnovationPortal_Ideas,
       Defaults(InnovationPortal_Ideas),
       {
          Title: txtTitle.Text,
          Short_description: txtShortDesc.Text,
          Long_description: txtLongDesc.Text,
          Status: cboStatus.Selected,
          Submitted_date: dateSubmitted.SelectedDate,
          User:
    ​​​​​​​ { Claims: "i:0#.f|membership|" & Lower(cboUser.Selected.Mail), Department: "", DisplayName: cboUser.Selected.DisplayName, Email: cboUser.Selected.Mail, JobTitle: " ", Picture: " " }, Category: cboCategory.SelectedItems, IsNew: true } );
    Also you do not need the odata reference any more.

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard