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

Patch causes no item to be displayed, problem is sporadic

Someone please help, I have tried many different methods for updating a field in a SharePoint list with little success. My current code works on a physical phone 50%, and maybe 20% in demo mode on the web. I have a toggle that records the time a driver leaves to pick someone up and the time they arrive, the toggle has a patch command that periodically wipeout data on my edit form (on that screen). I have tried submitform, resetform will little success, I want to stay on the same screen and not navigate way if possible (this is the first leg of a trip, all said I could end up with 8+ toggles= 8 to16 screens based on what is recorded).

Toggles are physically outside of the form,  and have no data connection to any field in the SharePoint list.

Thanks for any help.

1 ACCEPTED SOLUTION

Accepted Solutions

Tim, Thank you for your help. I ended up building 7 MS Flows to record timestamps in SP. I’m still able to use the Toggles and the form never need to refresh. I’m giving serious consideration to your suggestion of splitting the list and having a gallery below for stops.

Thanks again.

View solution in original post

6 REPLIES 6
TimRohr
Solution Sage
Solution Sage

Are you hard-coding the stop-number of each leg of the trip? Your screenshot had "leg1"... and you mentioned as many as 8... are you hard-coding that limit in (that is, you have 8 fields for up to 8 legs)?

 

Something to consider... your Gallery's Selected item is a Record, already. If it is pointing to the same SharePoint list that you're trying to Patch(), you don't need the First(Filter(....., ID = BrowseGallery1_2.Selected.ID) to arrive at the record to update... just pass the Selected record:

 

.....First(Filter(.....,BrowseGallery1_2.Selected, {driveronroutleg1: Now() }.......

I did as you suggested and cleaned up the patch command, 

Patch(tblAppTrips, BrowseGallery1_2.Selected,{driveronroutleg1: Now()	})

 It updates to my SharePoint list, but still having sporadic (50%) issues with my form losing data.

I do have 7 columns in my SharePoint list for recording times, planning on having 7 toggle’s to record each time (figured I put if statements in the visible command to control everything). Toggle one when true displays toggle two (false), Toggle two (true) toggle three (false), back and forth with GPS button updating as needed (see pic b). Until I can get this losing data on form under control I’m only using two toggles for testing.

Appreciate any other ideas.

TimRohr
Solution Sage
Solution Sage

Two things... when you say your form loses data, what do you mean? Do fields go blank? Does the form navigate away when you don't expect it to? Or does it commit a change, but then leave you in a place where you have to navigate to the appropriate record again?

 

Second... a suggestion. If your data were structured in terms of one SP list being your Trip (with info like Driver, Passenger, etc.), and another SP list being the stops for that trip, you could have as many stops as you wanted (within the limits of SharePoint lists, obviously). Your Trips list would have unique identifiers of the Trip, and the Stops lists would have that TripUniqueID plus other fields as necessary. One field would be this Time field you want to track.

 

Once you have that setup, you can have a screen where your trip stays present in the main portion (top), while the bottom is a Gallery of your Stops. Each item in the Gallery would have a button (not a toggle) to let the Driver mark the time that leg was begun. The button would write to that particular entry in your Stops list the timestamp of when the button was pressed. The button's Visible property would read whether the timestamp field had someting in it, so that if the field was filled already, you wouldn't see the button, but rather the timestamp.

 

Now you're not updating the Trip record, itself (and maybe running into refresh problems with viewing the thing you're trying to update)... you're updating the individual Stop record. Your screen shouldn't have to do much to refresh beyond just read the 2 visible properties (of the Time field and the button).

 

I'm a bit rushed at the moment, but if you want to go this route and need more input, post back and I'll try to help.

Tim, Thank you for your help. I ended up building 7 MS Flows to record timestamps in SP. I’m still able to use the Toggles and the form never need to refresh. I’m giving serious consideration to your suggestion of splitting the list and having a gallery below for stops.

Thanks again.

View solution in original post

Drrickryp
Super User
Super User

Hi @cmv,

Some or many of the problems you are running into could be corrected by properly designing the underlying data structure of your app. I believe that @TimRohr is alluding to this.  If you are planning on restructuring your app, please review my posts in the Community blog to better understand how to do this properly. Database Design Fundamentals and PowerApps: An Overview

TimRohr
Solution Sage
Solution Sage

Having a more normalized data structure can lead to more forward-scalable and future-bulletproof apps. For instance, having a flat record with an origin time and 7 stops means that you need 7 equations for figuring the duration:

Stop1 - Origin

Stop2 - Stop1

Stop3 - Stop2

etc.

With a relational structure, you have one equation that accounts for the Stop value (1, 2, 3, ...n ) and subtracts the Time for the Stop value 1 previous.

You also need, apparently, 7 flows.

And 7 toggles/buttons.

And then one day, a driver comes up to you and says they have a trip that requires 9 stops, and you either have to recode or you have to have the driver split that 1 trip across 2 records.

 

Archimedes said with a long enough lever (and a fulcrum), he could move the earth.

I will pitch my tent right next to his and say that with a properly normalized data schema, you can record any piece of data you may ever have a need to track.

 

...Ok, so, my tent is much smaller than his. But I'm pretty sure a lever never helped anyone store information in a logical way.

 

Pretty. Sure.

 

Come to the normalized side. We have donuts.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,082)