cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RNazareth
New Member

LoadData Function not responding properly

Hi

 

I am currently trying to build an offline solution for my app using the SaveData/LoadData functions. The logic I am using is that once a button gets pressed its patches the collection with boolean values in turn changing its display mode from edit to disabled. 

 

The concept works perfectly on the normal flow of the app, however, once I exit the app and the on start function loads the saved data from the collection, the displayed modes are maintained and the patch function stops working. 

 

I have been trying to fix this for the last 4 days and it's driving me insane... please someone help

 

 

 

OnStart: 

LoadData(HomeButtonHistory,"HomeButtonHistory_Saved",true);

 

Collection: 

 

Collect(HomeButtonHistory,{ID:ThisLog_Id,DB_Button_Home:true,STS_Button_Home:false,LWA_Button_Home:false,STC_Button_Home:false,STL_Button_Home:false,TBox_Button_Home:false});

 

Button Display mode: I have created a gallery linked to the HomeButtomHystory which I use to reference the status of the buttons)

 

 If(Button_Gallery.Selected.LWA_Button_Home=true,DisplayMode.Edit,DisplayMode.Disabled) 

 

Button OnSelect: 

 

Patch(HomeButtonHistory, LookUp(HomeButtonHistory,ID = ThisLog_Id) , {LWA_Button_Home:true, STC_Button_Home:false});

 

Thank you all in advance

 

RN

 

 

13 REPLIES 13
Pstork1
Dual Super User
Dual Super User

So I see the LoadData() in oNStart, but where in your app are you doing the SaveData()



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi Pstork,

 

Thank you for the reply.

 

I have currently wired the save data function throughout multiple screens after a button is pressed. 

 

Button On Select: 

Patch(HomeButtonHistory, LookUp(HomeButtonHistory,ID = ThisLog_Id) , {LWA_Button_Home:true, STC_Button_Home:false});

SaveData(HomeButtonHistory,"HomeButtonHistory_Saved")

 

Thank you once again to taking the time to assist.

 

RN

Are you testing on a Mobile app, Using a Web Browser, Or using Preview?

 

LoadData and SaveData only work on Mobile devices by default.

There is a preview feature that can be turned on to enable it in a Browser session.

Even with the feature enable it still doesn't work in Preview mode in the studio.

 

I tried something similar in a Mobile app and it works fine for me.

OnStart

LoadData(HomeButtonHistory,"ButtonSave",true);

Button OnSelect

Patch(HomeButtonHistory,LookUp(HomeButtonHistory, ButtonName=Self.Text),{ButtonName:Self.Text,ButtonStatus:false});SaveData(HomeButtonHistory,"ButtonSave");

Button DisplayMode

If(LookUp(HomeButtonHistory,ButtonName = Self.Text).ButtonStatus,DisplayMode.Edit,DisplayMode.Disabled)


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi,

 

Once again thank you for the reply! 

 

I have been testing the load data on an Ipad/phone apps. But still no solution

 

The collection and patch functions are all working as they should, however, once the data is loaded the buttons do not respond.

Below there a few screenshots.

Collection 

RNazareth_0-1637010435026.png

From the app

RNazareth_1-1637010636208.png

 

LWA Button Display mode: If(LookUp(HomeButtonHistory,ID = ThisLog_Id).LWA_Button_Home,DisplayMode.Edit,DisplayMode.Disabled)

 

What am I doing wrong!!!?!??!

 

Where are you getting the ID from that you are using in the Lookup?  Are you sure the Lookup is returning the value?  That's why I keyed my sample off the Text of the button label.  Buttons don't have an ID property that I'm aware of.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi

 

The Id is being generated at the On start -  Set(ThisLog_Id, GUID()); 

From there I add it to my collections as a unique reference...

 

I have also checked the lookup and it is correct...

 

RNazareth_0-1637015220943.png

Honestly, it's good that there are no bridges near me... I am almost ready to jump off one!! 🙂 

I get the placement of the ID in the collection.  But what ties that ID to the specific Button?  The idea is to lookup a reference for a specific Button.  But I don't see anything that ties that button to the record in the collection.  As I said, if you look at the example I did the Button.Text is added to the collection.  So by using the text of the button I can retrieve a specific record in the collection for that Button.  So I suspect the problem may be that after you re-load the connection the lookup doesn't relate to a specific button so the button doesn't change.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi,

Please accept my apologies in advance, but please bear with me, I have no IT background and I am learning all of this through videos and posts from people like your good self.  

My collection refers to the button name, status, and ID for a particular login. Is that not the requirement of a lookup function?

Collect(HomeButtonHistory,{ID:ThisLog_Id,DB_Button_Home:true,STS_Button_Home:false,LWA_Button_Home:false,STC_Button_Home:false,STL_Button_Home:false,TBox_Button_Home:false});

The lookup function returns the status as per my previous post. However, if the data is loaded (on a device) the function 

If(LookUp(HomeButtonHistory,ID = ThisLog_Id).LWA_Button_Home,DisplayMode.Edit,DisplayMode.Disabled)

Does not work!

Am I using the lookup incorrectly? 

 

Its OK if you aren't a programmer.  That's why we're here to answer questions. But to be able to use the Lookup to set the displayMode of a particular button there has to be something that ties that button to the setting.  So if you look at my example

 

If(LookUp(HomeButtonHistory,ButtonName = Self.Text).ButtonStatus,DisplayMode.Edit,DisplayMode.Disabled)

 

Lookup checks the HomeButtonHistory for the first record where the ButtonName stored in the record is equal to the Text used on the button (self.Text).  If ButtonStatus in that record is True then DisplayMode is Edit.  Otherwise its Disabled.  In your example you are comparing ID, which is a field in the Collection with ThisLog_Id which is a value in the collection.  Nothing ties that record to the Button.  So it doesn't know which button to apply the DisplayMode to.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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,051)