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 / DefaultSelectedItem us...
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:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    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

     
  • newbieappdeveloper Profile Picture
    22 on at
    You're an absolute star! Thank you!

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard