cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nanci 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
shailendra74 Solution Sage
Solution Sage

Re: Change items in local collections

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

Re: Change items in local collections

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,658)