i have collection(selected records from Gallery) in powerapps which contains 20 coloumn, now i want to patch few coloumns from collection to Sharepoint list. how to patch the code?
its working now, thanks for Support
If I understand correctly, your records are only being compared against the user's first record when patching?
I think the problem lies in the:
Filter(
MyCollection,
Not(ThisRecord.'Title' in LookUp('ABC', 'Created By'.Email = User().Email, Title))
)
LookUp only returns the first value it finds, so it will only compare your values to the first one created by the user. Try switching the code snippet above to something like:
Filter(
MyCollection,
Not(ThisRecord.'Title' in Filter('ABC', 'Created By'.Email = User().Email).Title)
)
Please note I haven't tested this code so you may have to play around with it a little bit.
again got some issue, here it checking duplicate record only 1st item, if i going to patching mutiple records.
RemoveIf(MyCollection, IsBlank('Title'))
If(!IsEmpty(MyCollection),
ForAll(
Filter(
MyCollection,
Not(ThisRecord.'Title' in LookUp('ABC', 'Created By'.Email = User().Email, Title))
),
Patch('ABC', Defaults('ABC'), { Title: ThisRecord.'Title' })
)
)
that makes sense, as it's likely still selected- if the collection is only being used to patch to the SharePoint list, you could clear it after the patch statement runs, which should solve this.
If you can't clear the collection quite yet, but you never want to have duplicate records in the list, you could also include something like:
If(
!(ThisRecord.Title in 'ABC'.Title),
Patch(...)
)
in your ForAll, just to ensure duplicates don't patch.
its working ,thanks for your Support.
one question, when user click submit button twice ,same selected records patching twice in list
Try:
If(
!IsEmpty(MyCollection),
ForAll(
MyCollection,
Patch(
'ABC',
Defaults('ABC'),
{
Title: ThisRecord.'Title'
}
)
)
)
Please also confirm that you have no records with a blank title in the collection-
This could be accomplished using something like, just prior to your Patch statement:
RemoveIf(
MyCollection,
IsBlank(Title)
)
Try something like:
If(
!IsEmpty(*YourCollection*),
Patch(...)
)
its working but if collection is empty and when user click submit button , it is creating empty record in SP list. how to avoid this?
I'm assuming your SharePoint list and collection are set up similarly. To patch items from a collection as new items, you could try something along the lines of
ForAll(
*YourCollection*,
Patch(
*YourSPList*,
Defaults(*YourSPList*),
{
Value1: ThisRecord.Value1,
Value2: ThisRecord.Value2,
Ect.
}
)
)
To update records instead of creating new ones, specify the record to update instead of using Defaults(YourSPList) in your patch statement.
For more info on Patch, see The Documentation
Hope this helps!
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional