cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lukas1
Advocate III
Advocate III

Best way to update multiple items from collection to sharepoint or dataverse

Hi,

 

in my App all data is stored in collections and when the user clicks a synchronisation-button the changed items are updated in the corresponding sharepoint list. (This is needed because the app is being used in offline mode)

 

Currently I am using this code to update multiple items:

ForAll(
    Filter(
        RenameColumns(
        My_Collection;
            "ID";
            "EditID"
        );
        item_action="edit"
    );
    Patch(
        My_Sharepoint_List;
        LookUp(
            My_Sharepoint_List;
            id = EditID
        );
        {
            Column1:Column1
            Column2:Column2
            Column3:Column3
            Column4:Column4
            ....
        }
    )
)
   

 

This code is working fine but I want to improve it in two ways:

1. Get rid of the ForAll loop to increase performance

2. The collection and the sharepoint list are exactly the same. Nevertheless, in the above code I have to map the sharepoint columns with the columns of the collection. This is hard to maintain. Is there a better solution for this?

 

Thanks!

Lukas

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AmDev
Super User
Super User

Hi @Lukas1 

 

If the schema in your collection is the exact same as your SharePoint list, it should be possible to just patch the collection to the datasource:

 

Patch(YourList, Filter(YourCollection, item_action = "edit"))

 

Hope this helps

View solution in original post

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @Lukas1 ,

If all the fields "line up" from your Collection with the List (all fields in the Collection are in the List with the same names and field types and includes the ID), you can do this

Patch(
   My_Sharepoint_List;
   My_Collection
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

AmDev
Super User
Super User

Hi @Lukas1 

 

If the schema in your collection is the exact same as your SharePoint list, it should be possible to just patch the collection to the datasource:

 

Patch(YourList, Filter(YourCollection, item_action = "edit"))

 

Hope this helps

Sorry @WarrenBelz didnt realise you were on this one 

@AmDev ,

You actually picked up the filter I missed

@Lukas1  - @AmDev 's solution is correct here

Lukas1
Advocate III
Advocate III

@AmDev and @WarrenBelz , thank you both, it works this way but it results in the next problem: When working with Dataverse I get the error "{VersionNumber}: The specified column is read-only".

 

I found this post regarding this issue. But the solution would again force me to write down each column individually.

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/The-specified-column-is-read-only-and-can-t-...

 

@Lukas1 ,

You referred to My_SharePoint_List and I responded accordingly. Dataverse is another beast and operates differently. I am a SharePoint user, so will leave you with @AmDev if you are heading down that direction.

@WarrenBelz and I am glad that I know about this solution for sharepoint related projects now 🙂 So thanks again and sorry for the misleading problem description (I thought/hoped there is no difference between SP and DV in this case)

Hi @Lukas1 -Sorry I cannot be of any further help on the Dataverse question as I too mainly focus on SharePoint solutions at present.

 

You could sit tight and see if anyone picks up this thread who has more of a DV background or you might get more engagement by reposting specifically on the residual DV query.

 

Good luck!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,628)