cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Patch Gallery.Selected reverts to first item in List

Hi All,

I've tried not to post here again as I was content on completing this task independently. But after around 5-6~ hours on this 1 formula alone I've given up. (I also have purple links on the first 2 pages of google results of any posts similar to this)

To summarize: I have a gallery that takes data from a SharePoint list. The gallery contains around 20  items (customers). Each customer has 2 tasks associated to them daily: Unload and Load. 
The issue I'm dealing with is keeping track of who has done what in an 'Unloaded/Loaded by who' format. Keeping in mind if say an employee has to leave work early for whatever reason, they would have to pickup where the original employee left.

From what I've read about this 'bug' is that upon patching inside a Gallery.Selected, the data source is refreshed, and you're brought to first item on your list, due to a SortByColumn() formula in the Items of the gallery.
I use 2 SortByColumn() formulas in my Item section and they're quite essential to the main menu, so a work around is required.

The 2 solutions I've attempted are:

On Change of the Unloaded drop down.

 

 

Patch('Datasource', ThisItem, {'Unloaded by': User().FullName})

 

 

 

As soon as the on change occurs, the data source refreshes and I'm brought to the first item in the gallery which will most likely cause errors with users down the line.

The second was to contain some extra labels with their text set as a variable named (unload): UL
Using the on-change menu item once again:

 

 

Set(UL, User().Fullname)

 

 

and have it displayed in the form also, then once a user submits:

 

 

Patch('Datasource', Gallery.Selected, {'Unloaded By': UL})

 

 


But I ran into problems with resetting the variable once the form is submitted and another is opened (the variable still says as the user's name despite them not interacting with the new customers form). As well as resetting the 'Unloaded by' if a user opens a customers form, makes a change, then realises they're at the wrong one and attempts to back out, yet they've already gone and patched the data.

Lastly, I've attempted having nothing patch immediately and having the submit entries button act as a final save and submit, but I run into issues with not all forms being patched in some mega formula or issues arising with the whole 'somebody has to take over halfway' problem.

So this is where I stand hahaha. Thanks for reading through this wall of text, I just wanted to ensure nobody wasted time by presenting an idea I've already tried. Any and all input is greatly appreciated. I'll be quite active on this forum for a while so let me know if anything needs any clarification.


Thanks!



 

 

Capture.PNG

Capture2.PNG

1 REPLY 1
Advocate II
Advocate II

have you tried putting a ForAll on the submit button?

 

something like

 

Forall(gallery.allitems,

patch('Datasource',thisitem,{'unloadedby': UL} )

 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (60,121)