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 / Saving data to SharePo...
Power Apps
Answered

Saving data to SharePoint List with "Peron or Group" field

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a SharePoint list that includes a field of type "Person or Group" linked to Office 365. Works great in SharePoint and mostly works on my PowerApp Mobile app.

 

I have about 10 fields - mostly text, a  few listboxes and and file attachment object.  Like many others, I've struggled with the various forms of data persistence.  Since I broke up my app into 3 edit forms I understand that I must use a  the Patch() function to save new records.

 

I successfully added the code (below) to the "Next" button at the bottom of the screen that includes the input that supports the "Person or Group" field.  So, whenever I pick a name and I'm in Edit mode it successfully saves the my choice to my SharePoint list 100% of the time.  However, I still need to use the Patch for my final screen that must add a new record with all data from all 3 forms.  Can anyone help with the PowerApps Patch syntax for including the "Person or Group" object.

 

// ------------------------------------------------------------------------------------------

//  If app is editing an existing record - use the SubmitForm to Save this form's data.

If(
    EditForm1.Mode = FormMode.Edit,
    SubmitForm(EditForm1);EditForm(EditForm2),
    NewForm(EditForm2)
);
    Navigate(
        EditScreen2,
        ScreenTransition.Fade
)

 

 

If I add something like the following into my Patch command for Adds 

 

{Managers: lstManagers.Selected},

 

The code window shows me the following error when I hover over the angry line of code:

 

"The type of this argument 'Managers' does not match the expected type 'Table' . Found type 'Record'.

 

Once I understand the syntax for using Patch with "Person or Group", I will elimnate the sloppy approach I took to inserting the SubmitForm in a Next button in the middle of the app. However, it worked and made me slightly happy.

 

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    If you're going to manually Patch a record that has a Person column in it, you will need to use this syntax in your Formula:

    {Managers:
    {   '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",   Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email),   Department:"", DisplayName:lstManagers.Selected.Department,   Email:lstManagers.Selected.Email,   JobTitle:".",   Picture:"." }
    }

    I put in your lstManagers in the above formula, so, you should be able to put this in place of your other formula.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the syntax - I've seen something similar in other posts and for some reason my  solution does not like it. I added the code that you provided (thank you) and I still get the same complaint.  

     

    "The type of this argument 'Managers' does not match the expected type 'Table' . Found type 'Record'.

    followed by

    "The function 'Patch' has some invalid arguments"

     

    Patch
    (
    'CI Idea Board', Defaults('CI Idea Board'),
    {Title: txtTitle.Text},
    {Description: txtDescription.Text},
    {ProposedSolution: txtProposedSolution.Text},
    {Comments: txtComments.Text},
    {Authors: txtAuthors.Text},
    {Resolution: txtImplementation.Text},
    {ImpactTime: Value(txtImpactTime.Text)},
    {ImpactCost: Value(txtImpactValue.Text)},
    {FSFCDepartment: lstDepartment.Selected},
    {Status: lstStatus.Selected},
    {Managers:
    {
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email),
    Department:"", DisplayName:lstManagers.Selected.Department,
    Email:lstManagers.Selected.Email,
    JobTitle:".",
    Picture:"."
    }
    },
    {CIImpactTypes: lstImpactType.Selected}
    )

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    How is your column set up in SharePoint?  

    My guess is that you have it setup to allow multiple selections.  If so, then yes, you need to provide a table of selections to the field.

     

    Change your formula to the following (and by the way, I noticed I had a mistake in my previous post in the formula...it is corrected below):

     

    Patch('CI Idea Board', 
    Defaults('CI Idea Board'), {Title: txtTitle.Text, Description: txtDescription.Text, ProposedSolution: txtProposedSolution.Text, Comments: txtComments.Text, Authors: txtAuthors.Text, Resolution: txtImplementation.Text, ImpactTime: Value(txtImpactTime.Text), ImpactCost: Value(txtImpactValue.Text), FSFCDepartment: lstDepartment.Selected, Status: lstStatus.Selected, Managers:
    Table(
    { '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email), Department: lstManagers.Selected.Department,
    DisplayName:lstManagers.Selected.DisplayName, Email:lstManagers.Selected.Email, JobTitle:".", Picture:"." }
    ), CIImpactTypes: lstImpactType.Selected
    } )

    See if that gets you to the next step.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you!  I appreciate your willingness to help as well as your advanced skills.  I've developed in many languages and just started with PowerApps last month.  Most of it is straight forward and something you can read the documentatation and figure out but I was sucking wind on that Patch command - or at least when something I was doing on the Patch command needed something like "

    #Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser 

    Thanks again for solving my problem.  I spent hours experimenting and searching and reading before I sent up the flare.   

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Oddly if I attempt to creat a new item without selecting an Manager (not a required user input) it fails to add the record.  If I then attempt to make the exact same entry with a Manager selected is saves.

     

    In the fist case I find that there is a Runtime error recorded.  It references this data save section.  When I open the data save code and hover over the "now underlined code" that contains the table logic is says:

     

    FSFCDepartment: Field required

     

    Which is indeed a required field but one that I entered data into before clicking save.

     

    I'm quite certain the error is due to the fact that there is no selection made in the lstManagers control yet it is calling out an unrelated control.

     

    My next question is, does the logic you provided for me to write the table data need to be wrapped in IF() logic so it doesn't try to write the data if nothing was picked?  It's the only difference between my two test runs.

     

    Thoughts? 

     

    Thanks again

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Hmmm, without doing a quick test on it, I would offer the following adjustment then to your formula:

     

     

    Patch('CI Idea Board', 
     Defaults('CI Idea Board'),
     {Title: txtTitle.Text,
     Description: txtDescription.Text,
     ProposedSolution: txtProposedSolution.Text,
     Comments: txtComments.Text,
     Authors: txtAuthors.Text,
     Resolution: txtImplementation.Text,
     ImpactTime: Value(txtImpactTime.Text),
     ImpactCost: Value(txtImpactValue.Text),
     FSFCDepartment: lstDepartment.Selected,
     Status: lstStatus.Selected,
     Managers:
    If(!IsBlank(lstManagers.Selected.Email),
    Table( { '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email), Department: lstManagers.Selected.Department, DisplayName:lstManagers.Selected.DisplayName, Email:lstManagers.Selected.Email, JobTitle:".", Picture:"." } )
    ), CIImpactTypes: lstImpactType.Selected } )

     

    That should change that issue.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yup that was it.  I found some blogs referencing isEmpty and wouldn't have thought to look at the .Email .  I'm looking forward to working on something else... . 😉  Thanks again!


    @RandyHayes wrote:

    @Anonymous 

    Hmmm, without doing a quick test on it, I would offer the following adjustment then to your formula:

     

     

    Patch('CI Idea Board', 
     Defaults('CI Idea Board'),
     {Title: txtTitle.Text,
     Description: txtDescription.Text,
     ProposedSolution: txtProposedSolution.Text,
     Comments: txtComments.Text,
     Authors: txtAuthors.Text,
     Resolution: txtImplementation.Text,
     ImpactTime: Value(txtImpactTime.Text),
     ImpactCost: Value(txtImpactValue.Text),
     FSFCDepartment: lstDepartment.Selected,
     Status: lstStatus.Selected,
     Managers:
    If(!IsBlank(lstManagers.Selected.Email),
    Table( { '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email), Department: lstManagers.Selected.Department, DisplayName:lstManagers.Selected.DisplayName, Email:lstManagers.Selected.Email, JobTitle:".", Picture:"." } )
    ), CIImpactTypes: lstImpactType.Selected } )

     

    That should change that issue.

     



    @RandyHayes wrote:

    @Anonymous 

    Hmmm, without doing a quick test on it, I would offer the following adjustment then to your formula:

     

     

    Patch('CI Idea Board', 
     Defaults('CI Idea Board'),
     {Title: txtTitle.Text,
     Description: txtDescription.Text,
     ProposedSolution: txtProposedSolution.Text,
     Comments: txtComments.Text,
     Authors: txtAuthors.Text,
     Resolution: txtImplementation.Text,
     ImpactTime: Value(txtImpactTime.Text),
     ImpactCost: Value(txtImpactValue.Text),
     FSFCDepartment: lstDepartment.Selected,
     Status: lstStatus.Selected,
     Managers:
    If(!IsBlank(lstManagers.Selected.Email),
    Table( { '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", Claims:"i:0#.f|membership|" & Lower(lstManagers.Selected.Email), Department: lstManagers.Selected.Department, DisplayName:lstManagers.Selected.DisplayName, Email:lstManagers.Selected.Email, JobTitle:".", Picture:"." } )
    ), CIImpactTypes: lstImpactType.Selected } )

     

    That should change that issue.

     


     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Excellent!  Yes, IsEmpty can work as well, but, as a general rule, I tend to use the IsBlank on a specific field of the data.  Reason is, IsEmpty sometimes does not return what you think it might on some types of data.  IsBlank is a good ol' fail-safe.

    Good luck with the next step!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    One more (I think) question about this Table method.  If I select 5 people in the screen selector and Save or Update, it only saves the last selection.  

     

    Is there something you have to do to tell it to save all selections?

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Ah yes, the solution provided only deals with one selected user.

    Let's give this a shot...

    Patch(
    …
    ...
     Managers:
     If(CountRows(lstManagers.SelectedItems)>0,
     ForAll(lstManagers.SelectedItems,
     {
      '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",  Claims:"i:0#.f|membership|" & Lower(Email),   Department: Department, DisplayName: DisplayName, Email: Email, JobTitle: ".",   Picture: "." } ) ) } ...
    ...
    )

    I'm making a couple of assumptions here based on the Items property of your ComboBox. If I assumed correct, this should work as-is.

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,074

#2
Valantis Profile Picture

Valantis 639

#3
11manish Profile Picture

11manish 606

Last 30 days Overall leaderboard