cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Elitezone
Post Prodigy
Post Prodigy

Patch function - add two fields people sharepoint list

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

Ok, I just noticed why the code isn't working.  You are missing the closing '}' on the first person you are adding.  Each person needs to be saved as a record.  So your {}'s don't match.  That's why its not seeing the second person.

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:"", <--- This comma should be a } closing brace
  '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:""
   }}
  })


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

12 REPLIES 12
Pstork1
Dual Super User III
Dual Super User III

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.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@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
Dual Super User III
Dual Super User III

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. 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@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
Dual Super User III
Dual Super User III

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 

I made an entry and picked myself.

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

Pstork1
Dual Super User III
Dual Super User III

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@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
Dual Super User III
Dual Super User III

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



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (51,814)