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

Does anyone know ?

Helper I
Helper 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

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!

Helper I
Helper 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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,881)