cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rwittels
Resolver I
Resolver I

Error checking LoadData

I have a form over multiple screens which saves to a collection called "Checklist". On each screen, when the next button is pressed, I save Checklist to the device so that the user can continue the next day if they wish.

When the user opens the app, they will get 2 options: "Continue Previous Session" or "Start New Checklist".

I want "Continue Previous Session" to be disabled if no saved data exists and to be selectable if data exists.

I have tried these 3 on DisplayMode but none work:

 

If(IsError(LoadData(Checklist, "LocalCache")), Disabled, Edit)
If(IsBlank(LoadData(Checklist, "LocalCache")), Disabled, Edit)
If(IsBlankorError(LoadData(Checklist, "LocalCache")), Disabled, Edit)

 

I am also thinking that maybe I need to check if "LocalCache" exists but not sure how.

If I attempt to LoadData that doesn't exist, I get this error in the mobile app:

Screenshot_20210713-160346_Gallery.png

 

 

 

 

 

I am trying to catch this error and disable my button without displaying the error. Unless there is a simple way to check if a local save exists or not.

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 need to be able to do something if there is an error.

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 ( ... ) ).

1 ACCEPTED SOLUTION

Accepted Solutions
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.

View solution in original post

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

View solution in original post

I have found using IsEmpty on the data works for first runs.

LoadData(sessionInfo,"mySessionInfo",true);

If(IsEmpty(sessionInfo),<no saved data>,<saved data>);

 

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 (3,645)