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

How to Update multi user field/column using Patch()?

Hello,

 

I have came across scenario where I need to update SharePoint list mutiuser field called "InterestedIn".

Here multiple users can register their interests in particular list item using a button which says "I am interested"

on this button I need to add/append current user to the list column "InterestedIn"

 

Below is my code on button click, some how i need to add current user to existing users in columns and then Patch()

 

Patch(
GrabOpp,
galOpenOpportunities.Selected,
{
InterestedIn:Table(
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
})
}
)
Thanks. 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

If any one reading this, I have found solution to this,
using Collection: 

Step 1: Collect all existing users in collection:
Collect(InterestedUsers,galOpenOpportunities.Selected.InterestedIn)

Step 2: Add new user to Collection:

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

Step 3: Now Patch the updated collection directly in Patch() function.
Patch(
GrabOpp,
galOpenOpportunities.Selected,
{
InterestedIn:InterestedUsers
}
)
Bingo.. 🙂


View solution in original post

10 REPLIES 10
Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

Does anyone know ?

Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

If any one reading this, I have found solution to this,
using Collection: 

Step 1: Collect all existing users in collection:
Collect(InterestedUsers,galOpenOpportunities.Selected.InterestedIn)

Step 2: Add new user to Collection:

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

Step 3: Now Patch the updated collection directly in Patch() function.
Patch(
GrabOpp,
galOpenOpportunities.Selected,
{
InterestedIn:InterestedUsers
}
)
Bingo.. 🙂


View solution in original post

Highlighted
New Member

Re: How to Update multi user field/column using Patch()?

This is not working for me. whenever I'm trying to update it always update the current users and remove the previous user.

 

Collect(InterestedUsers,Events.AcceptedBy);

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

 

Patch(Events,First(Filter(Events,ID=ThisItem.ID)),{AcceptedBy:InterestedUsers})

 

 

 

Note:

AcceptedBy is the multi valued person column

Events is the list name

 

Highlighted
Advocate I
Advocate I

Re: How to Update multi user field/column using Patch()?

Thanks a lot! This was a quick and elegant solution!

Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

I want to patch not only the first element of a filtered collection.

 

How can I patch every Phonenumber which is "" to "9-999-999-9999" - so we can sort the collection by phonenumbers a bit better?

 

In my special case I have a table of orders and want to sort by next estimated delivery date, but dates are sometimes empty and will be always on top when sorting.

 

I already tried:

 

//changes only first row of the filter:

Patch( Customers, First( Filter( Customers, Phone = "" ) ), { Phone: "9-999-999-9999" } )     

 

//having syntax error:

Patch( Customers,  Filter( Customers, Phone = "" ), { Phone: "9-999-999-9999" } )

 

Highlighted
Advocate I
Advocate I

Re: How to Update multi user field/column using Patch()?

You may try something like this: ForAll(Filter( Customers, Phone = "" ),Patch(Customers,ThisRecord,{ Phone: "9-999-999-9999" })

Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

thanks a lot - this works.

Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

this works, but makes my powerapps hanging off for a few minutes every time it is running 😞

 

function: yes

performance: really bad

user acceptance: NOOO!

Highlighted
Helper I
Helper I

Re: How to Update multi user field/column using Patch()?

are there other - more performant - solutions for this?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,973)