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 / Patch function - add t...
Power Apps
Answered

Patch function - add two fields people sharepoint list

(0) ShareShare
ReportReport
Posted on by 909

Hello,

 

I have a patch function like that:

 

 

Patch(
 Obrazy_obecnosc, 
 Defaults(Obrazy_obecnosc),
 {
 Title: TextInput2.Text,
 'Informacje o obrazie': First(CameraImage).Url,
 'Nawigacja kod pocztowy':TheVar.address.postalCode,
 'Nawigacja pełen adres':TheVar.address.formattedAddress
 })

 


It works well, but I would love to allow to patch two more fields.

1. ImiÄ™ i nazwisko (Forename and Surname) - people field in sharepoint

2. Manager - people field in sharepoint that is chosen from ComboBox that has item property like that:

 

Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:10})

 

 

How can I achieve that?

Or should I convert those fields from people to plain text?

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,547 Most Valuable Professional on at

    To Patch a User field you need to supply the user data in the format of a record.  Each of the following fields are required 

     

    {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims:"i:0#.f|membership|" & UserEmail,
     Department:"",
     DisplayName: UserFullName,
     Email: UserEmail,
     JobTitle:"",
     Picture:""
     }

     

    So your patch statement would look something like this

     

     

    Patch(
     Obrazy_obecnosc, 
     Defaults(Obrazy_obecnosc),
     {
     Title: TextInput2.Text,
     'Informacje o obrazie': First(CameraImage).Url,
     'Nawigacja kod pocztowy':TheVar.address.postalCode,
     'Nawigacja pełen adres':TheVar.address.formattedAddress,
     'User Field': {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims:"i:0#.f|membership|" & UserEmail,
     Department:"",
     DisplayName: UserFullName,
     Email: UserEmail,
     JobTitle:"",
     Picture:""
     }
     })

    Fill in the appropriate Claims, Email and DisplayName from a dropdown or a lookup or whereever.

     

  • Elitezone Profile Picture
    909 on at

    @Pstork1 

    OK I have added with no effort field 'ImiÄ™ i nazwisko" which is supposed to show the name of person that is performing action.

    "Przelozony" which is supposed to save a value from combobox that present 365 users data is on a whole another level for me...

     

    I created a formula that supposedly should work, but it doesn't. It does not show any errors:

     

    Patch(
     Obrazy_obecnosc, 
     Defaults(Obrazy_obecnosc),
     {
     Title: TextInput2.Text,
     'Informacje o obrazie': First(CameraImage).Url,
     'Nawigacja kod pocztowy':TheVar.address.postalCode,
     'Nawigacja pełen adres':TheVar.address.formattedAddress,
     'ImiÄ™ i nazwisko': {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims:"i:0#.f|membership|" & User().Email,
     Department:"",
     DisplayName: User().FullName,
     Email: User().Email,
     JobTitle:"",
     Picture:"",
     'Przełożony': {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims:"i:0#.f|membership|" & ComboBox1.Selected.Mail,
     Department:"",
     DisplayName: ComboBox1.Selected.DisplayName,
     Email: ComboBox1.Selected.Mail,
     JobTitle:"",
     Picture:""
     }}
     })

    So everything is filled except 'Przelozony'

     

    Items of this ComboBox:

    Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:10})

     

  • Pstork1 Profile Picture
    69,547 Most Valuable Professional on at

    Toss a couple labels onto the screen temporarily and set them to 

    ComboBox1.Selected.Mail
    ComboBox1.Selected.DisplayName

    That should tell you if you are reading the right values from the Combo Box.  Otherwise it looks correct.  I suspect you need to use something different to get the values you want from the ComboBox. 

  • Elitezone Profile Picture
    909 on at

    @Pstork1 

    Both 

     

    ComboBox1.Selected.Mail
    ComboBox1.Selected.DisplayName

     

    works correctly in a label.

    They show a value that I have selected in ComoBox1. 

     

    It even preview this value in formula section:

    Elitezone_0-1603809252953.png

    I have no idea why this won't work.

  • Pstork1 Profile Picture
    69,547 Most Valuable Professional on at

    The only other thing I can think of is that the user you've selected isn't a member of the SharePoint site where you are trying to save them.  Otherwise if those values are correct then it should work.  To test that theory try picking the same user from the ComboBox that you are using for the other entry.  If it works then its something about that user, not the syntax.

  • Elitezone Profile Picture
    909 on at

    @Pstork1 

    I made an entry and picked myself.

    One field got filled with my name but "Przelozony" is still empty

  • Pstork1 Profile Picture
    69,547 Most Valuable Professional on at

    And "Przelozony" is a regular People column set for a single entry?  If it allows multiple choices the syntax needs to be an array or records, not just a record.

  • Elitezone Profile Picture
    909 on at

    @Pstork1 

    In Sharepoint both fields are a single choice person fields.

    Also in PowerApps ComboBox has a single choice setting preventing users from picking more than one choice.

     

    They are basicly identical fields as their purpose is very similar.

  • Pstork1 Profile Picture
    69,547 Most Valuable Professional on at

    As far as I can see then the code you have in place should work.  I'm not sure what else to suggest.

  • Elitezone Profile Picture
    909 on at

    @Pstork1 

    Thank you for your help.

     

    Does anyone else have idea what to do in this matter?

    Can this function be remodelled?

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 474

#1
Valantis Profile Picture

Valantis 474

#3
WarrenBelz Profile Picture

WarrenBelz 375 Most Valuable Professional

Last 30 days Overall leaderboard