cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
taramoe
Advocate II
Advocate II

Patch SharePoint person or group

I have a gallery where I need to update an individual SharePoint record in a list called 'Meeting Schedule'.  I can't quite seem to get the syntax or code correct to update the Person/Group field in the SharePoint list.  I'm basically clearing out a whole group of fields and setting them to blank.  The field 'SSM' is the People/Group field. 

 

Patch('Meeting Schedule',ThisItem,

{Title:"", Location: "",
SSM:

{'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Claims: "",
Department: "",
DisplayName: "",
Email: "",
JobTitle: "",
Picture: ""}
})

1 ACCEPTED SOLUTION

Accepted Solutions
HadynM
Continued Contributor
Continued Contributor

Aaaaahhhh my mistake, sorry.

Using MS Flow is the only way I've been able to get it to work.

This article gives a good indication of how to do it:

https://poszytek.eu/en/microsoft-en/office-365-en/powerapps-en/clear-lookup-and-people-picker-fields...

If you haven't used the sharepoint http request action before the following line gave me the most trouble:

"__metadata":{"type":"SP.Data.MyListNameListItem"}

It is a double underline at the start and the name of your list in bold.

I would be interested if you figure out how to do it directly from PowerApps.

Cheers

Hadyn

View solution in original post

7 REPLIES 7
HadynM
Continued Contributor
Continued Contributor

Hi @taramoe

A great response from @v-micsh-msft on this post:

https://powerusers.microsoft.com/t5/General-Discussion/Saving-data-from-powerapps-to-SP-lists-person...

 

I create a variable for each claim (person) that I want to include in a patch:

Set(requesterClaim,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   });
Set(newBooking, 
    Patch(CafeteriaBookings,Defaults(CafeteriaBookings), {
        Title: "Booking",
        Requester: requesterClaim,
        Reason: tiReason.Text,
        docHTML: htmlDoc,
        PreviousState: ""
    })
)

The Claims, DisplayName, and Email are the required fields.

Hope that helps

Hadyn

Thanks @HadynM

 

I'm trying to null out the person/group field and I don't think the below solution addresses that?  Please correct me if I'm wrong.  My goal is to clear out the field and this is where I'm stuck.  Thanks for any help you can provide.

HadynM
Continued Contributor
Continued Contributor

Aaaaahhhh my mistake, sorry.

Using MS Flow is the only way I've been able to get it to work.

This article gives a good indication of how to do it:

https://poszytek.eu/en/microsoft-en/office-365-en/powerapps-en/clear-lookup-and-people-picker-fields...

If you haven't used the sharepoint http request action before the following line gave me the most trouble:

"__metadata":{"type":"SP.Data.MyListNameListItem"}

It is a double underline at the start and the name of your list in bold.

I would be interested if you figure out how to do it directly from PowerApps.

Cheers

Hadyn

View solution in original post

Thanks @HadynM, I'll give it a try.  Appreciate the help.

Hi @HadynM - Just wanted to say thank you for your help here.  I had abandoned working on this for awhile and came back to it recently and your tips were enormously helpful and it's working beautifully in Flow.  I plan to call the flow from PowerApps or use some other Flow trigger (haven't figured this part out yet but shouldn't be too complicated).

Thanks again!

 

This also worked for me, I changed the code a little, but it worked like a charm!

 

Patch( 'FiveWhysSettings', First( Filter( 'FiveWhysSettings', Title = FixedPlant")),
{
ReliabilityEngineer: ComboBoxJobPerson.Selected.Value, 

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:ComboBoxJobPerson.Selected.Claims,
    Department:ComboBoxJobPerson.Selected.Department,
   DisplayName:ComboBoxJobPerson.Selected.DisplayName,
         Email:ComboBoxJobPerson.Selected.Email,
      JobTitle:ComboBoxJobPerson.Selected.JobTitle,
       Picture:ComboBoxJobPerson.Selected.Picture
   }
}
)

 

I am trying to create an item in SharePoint list from Canvas App, and I need to pass the current user name to 'Person or Group' column of SharePoint, Hadyn solution worked well.

Set(requesterClaim,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   });

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,003)