cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SudhirSingare
Advocate I
Advocate 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
SudhirSingare
Advocate I
Advocate I

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
SudhirSingare
Advocate I
Advocate I

Does anyone know ?

SudhirSingare
Advocate I
Advocate I

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.. 🙂


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

 

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

PowerDapp2
Advocate I
Advocate I

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" } )

 

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

thanks a lot - this works.

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!

are there other - more performant - solutions for this?

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,282)