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

Trying to trap the Error on using LoadData & SaveData using

Hi,  
IfError doesn't seem to trap the error generated if the SaveData or LoadData fails. It's useful to trap this because when in a browser, these functions do not work. But more importantly, on a device, I want to load a local "Settings" file. If it is not present first time around when app is first run, I want to handle it elegantly. I have developed a work-around (Happy to share), but Powerapps still displays a rather annoying notify error. Am I missing something, using the wrong function(s). Maybe someone else has had a similar experience. Thanks

 

Set(LocalFileName, "SavedSettings");
ClearCollect(colSettings, {
    Font: "Verdana",
    FontSize: 80
});
IfError(SaveData(colSettings, LocalFileName),Notify("Error Saving"));
IfError(LoadData(colSettings, LocalFileName, false),Notify("error"));

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
alrez
Community Support
Community Support

Hi,

 

Thanks for your post and I am glad that we have a work around to this even if you are still getting errors. Looking through, I don't see any reason why this error should still be occurring for you. Maybe this would be a better question for the Microsoft Support team. I'll include a link on how to reach out to them if you would like to go down that route. Otherwise if any other communities members might know feel free to chime in.

 

If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so: https://docs.microsoft.com/en-us/power-platform/admin/get-help-support

 

Regards,

 

Alex

 

-------

 

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

View solution in original post

3 REPLIES 3
alrez
Community Support
Community Support

Hi,

 

Thanks for your post and I am glad that we have a work around to this even if you are still getting errors. Looking through, I don't see any reason why this error should still be occurring for you. Maybe this would be a better question for the Microsoft Support team. I'll include a link on how to reach out to them if you would like to go down that route. Otherwise if any other communities members might know feel free to chime in.

 

If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so: https://docs.microsoft.com/en-us/power-platform/admin/get-help-support

 

Regards,

 

Alex

 

-------

 

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

View solution in original post

rwittels
Resolver I
Resolver I

Please share your workaround.

LoadData when no SaveData is present on a mobile device gives this error:

LoadData_Errors.png

 

I know I can suppress the error using:

"IgnoreNonexistentFile - Optional. A Boolean value indicating what to do if the file doesn't already exist. Use false (default) to return an error and true to suppress the error."

But I would also like to "elegantly" catch these errors. If data is present and there is no error, I need to navigate to a new screen. If there is an error, I don't want to navigate anywhere, I want to notify the user that there is no data present.

Currently, based on my tests, using Errors, IfError or IsError do not pick up the error when using "LoadData( Collection, Name , false)". This would be the easiest way to manage this.

It also doesn't work if I put LoadData() inside IsEmpty( Errors ( ... ) ).

rwittels
Resolver I
Resolver I

I have been approaching this incorrectly. I resolved this by doing the following:

App OnStart

LoadData(Checklist,"LocalCache",true)

I use "true" to suppress errors if there is no "LocalCache" file.

"Continue previous session" Button

DisplayMode

If(
   !IsBlank(First(Checklist).Employee) &&
   !IsBlank(First(Checklist).Username),
   Edit,
   Disabled
)

"Employee" and "Username" are two fields in my collection that cannot be blank. So if they are blank, it is likely that the collection did not load. The button is then disabled as there was no data loaded.

It's that simple actually. I tested it a few times and it works great.

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 (2,447)