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

Change items in local collections

I have an app where, in order to improve performance, I pull data from SharePoint lists and store it in collections. There is one screen where the user sees and edits some records.  The screen where the user edits the data should also immediately show the change.
Right now I have a gallery that shows the collection and an input box to edit a specific field in the record, once the user edits the field, the changes are sent to the Sharepoint lists and the collections are updated, but this process takes too long. Ideally, I'd like to allow the user to make all edits in the local collections and once the user navigates to a different screen, run a process in the background to update the data in the Sharepoint list. How can I do this?
The app is only used in the browser, never in a phone.

2 REPLIES 2
Anonymous
Not applicable

Hi @nanci 

 

Add an additional column to your local collection to keep track of all changes done.

 

AddColumns(mycollection, "MODIFIED", false) // default to false, update this on change of value in gallery


On change you can update the collection using patch which would update specific record in the gallery

 

Patch(mycollection, LookUp(mycollection, ID = ThisItem.myID), { Status: false, MODIFIED: true })


Once you are done with all updates, before navigating to new screen or onSelect of Update all, you can update all records to sharepoint

 

ForAll(
    Filter(
        mycollection,
        MODIFIED = true // only modified values are considered
    ),
    Patch(
        TestUpload,
        First(
            Filter(
                TestUpload,
                ID = myID  // splistitemid  = coll id
            )
        ),
        {spfieldname: collfieldname}
    )
)

Thanks

Community Support
Community Support

Hi @nanci ,

Based on the needs that you mentioned, I think PowerApps could achieve your needs.

 

I have made a test on my side, please take a try with the following workaround:

Set the OnHidden property of current screen where the user made changes to the local collection to following:

ForAll(
          YourLocalCollection,
          Patch(
                    'YourSPList',
                     LookUp('YourSPList', ID = YourLocalCollection[@ID]),
                     {
                       Column1: YourLocalCollection[@Column1],
                       Column2: YourLocalCollection[@Column2],
                       Column3: YourLocalCollection[@Column3],
                       ...
                     }
         )
)

Please take a try with above solution, check if the issue is solved.

 

More details about the ForAll function and Patch function, please check the following article:

ForAll function

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
News & Announcements

Community Blog

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

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (9,228)