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

5 REPLIES 5
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.

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.

kimxaviernati
Frequent Visitor

Hi, what is the solution to trap failures on Loaddata or SaveData?

joalva
Microsoft
Microsoft

Try using ifError as stated above, although do enable the Experimental feature "Formula-error level management"

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,808)