cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mlaurie
Helper I
Helper I

Patch not working within form with People Picker

Hello! I'm trying to get a patch function to work to recognize if a user has submitted the form before and if so, update preferences. 

 

Backstory: App is a simple form for signing into a company event. A user walks up and selects their name in the people picker field of the form and there are checkboxes below that ask if they would like to receive email communications in the future. The first time works great. I have a flow that looks up their department and email and inserts into the destination SharePoint list. 

 

When that same user goes to a future and wants to update their communication preferences I can't get it to see if the name selected in the people picker field exists so the record can be updated and not created new. 

 

Currently, the below patch function creates a NEW record with a blank name in the SharePoint list.

 

Patch('LIst Name',{Name:DataCardValue6.Selected},{'Preferences One':DataCardValue7.Text,'Preference Two':DataCardValue8.Text,'Preference Three':DataCardValue11.Text})

 

Am I having issues because it's a People Picker?

 

 

9 REPLIES 9
rebeccas
Super User
Super User

Are you trying to Patch a combo box (people picker) to a people field (SharePoint list)?

rebeccas
Super User
Super User

To patch a people field into a SharePoint list you would use something like this:

 

Patch(SPList, Defaults(SPList),

     {Title:"Whatever",

     PPLField: {

          DisplayName: ComboBox.Selected.DisplayName,

          Claims: "i:0#.f|membership|" & Lower(Combobox.Selected.Email),

          Department:"",

          Email: ComboBox.Selected.Email,

          JobTitle:"",

          Picture:""}

     }

)

 

 

I don't believe so. When I created the SharePoint list the column is a people picker and so I'm not sure it created a combo box when I connected the form to the SharePoint data source. 

If you are using a Form (which I always think is the better route)...what is your Patch doing? I am not understanding this part.

v-monli-msft
Community Support
Community Support

Hi @mlaurie .

 

Actually you do not need to add such a separated person and group field. By default, in SharePoint list, there is one field called "Author" which is created by SharePoint automatically when user submitting one item. You could check if current user exists in this field. The formula should be something like:

If(IsBlank(Lookup(ListName,Author.Email=User().Email)),Patch(ListName,Defaults(ListName),{Title:textinput1.Text,
PersonField:Dropdown.Selected}),
Patch(ListName,Lookup(ListName,Author.Email=User().Email),
{Title:textinput1.Text,
PersonField:Dropdown.Selected}))
   

This formula means that if current user is not included in the Author field, then create a new item. If current user already exists in the Author field, then edit this item.

 

If you are using the Form control, then for Patch function, you just need to copy and paste the formulas in the Update property of each data card for each field. 

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I'd like the patch to update the user's communication preferences if the name selected in the form matches a name that exists in the SharePoint list.

Will this work if I'm the one who opens the app and my "customers" come and sign in by selecting their name?

 


@v-monli-msft wrote:

Hi @mlaurie .

 

Actually you do not need to add such a separated person and group field. By default, in SharePoint list, there is one field called "Author" which is created by SharePoint automatically when user submitting one item. You could check if current user exists in this field. The formula should be something like:

 

If(IsBlank(Lookup(ListName,Author.Email=User().Email)),Patch(ListName,Defaults(ListName),{Title:textinput1.Text,
PersonField:Dropdown.Selected}),
Patch(ListName,Lookup(ListName,Author.Email=User().Email),
{Title:textinput1.Text,
PersonField:Dropdown.Selected}))
   

 

This formula means that if the current user is not included in the Author field, then create a new item. If the current user already exists in the Author field, then edit this item.

 

If you are using the Form control, then for Patch function, you just need to copy and paste the formulas in the Update property of each data card for each field. 

 

Regards,

Mona


 

Hi @mlaurie ,

 

User().Email returns the current logged in PowerApps user's email address. So I don't understand what you mean by "my "customers" come and sign in". 

 

If you share this app with a "customer", then he open the app from his PowerApps site. He will be the "current logged in user", and User().Email will become his PowerApps account email address in this app. 

 

For more information about User function, please refer to:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The scenario is the following:

 

I login to PowerApps on a tablet device. People walk into the event I'm hosting and enter their name and preferences on the device that I am logged into. We want their preferences to be updated if their name is already in the list from attending an event in the past where we had them enter their name and preferences before.

 

Sorry for any confusion.

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (74,610)