cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

App not storing storing infromation and refreshes

I'm having an issue with my screens on power apps. I am creating a timesheet app for employees in an organisation. Within the app I broke up the days into separate screens to make it more presentable.

 

So for Monday when they clock in and out it goes straight to the detailed screen, but when it comes to the other days it goes back to the day before screen and I'll now have to input the entries in again for that same day but the info I put in before would still be visible on the SharePoint list that storing the information. 

 

It started doing this when I created a button to navigate to the next day screen so I'm quite confused

19 REPLIES 19
Highlighted
Dual Super User II
Dual Super User II

Re: App not storing storing infromation and refreshes

The screens of an app don't normally store information, the SharePoint list does.  When you navigate away from a screen and then back to it the screen will normally refresh and display the defaults.  Which in your case is probably new entries.  I would need to see what you are doing in your app to provide a real solution.  But I suspect what you want is to set the fields to load the existing record from SharePoint, if its there, or provide a blank entry if its not.  That will require adding an IF() to the default property of the fields.



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

Re: App not storing storing infromation and refreshes

Yes it refreshed and the data was not stored on the same row but another row below it with nothing else and then when I want to clock out that new information is stored on the correct row but with no clock in included as it's still in the row below.

 

As you can see in the image the two rows with a red underline, a person has clocked in and the information for Monday have been stored whereas for Tuesday_start (clock in) , they clocked in but when it refreshed instead of storing on the same row it's stored in another row below.

Screenshot (129).png

Highlighted
Dual Super User II
Dual Super User II

Re: App not storing storing infromation and refreshes

Are you just submitting the form to store the information or using a Patch() statement?  I would use Patch() since it gives you more control when updating some fields but not others in an existing row.



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

Re: App not storing storing infromation and refreshes

How would I do that, I have really used patch function so I'm not sure. I have a total of 6 screens and I made it that once an entry has been added in each day that the next page to show would be the edit form that shows what been added but instead it doesn't do that, so maybe the patch would be a perfect method but the problem would be how to go about it.

 

 

Highlighted
Dual Super User II
Dual Super User II

Re: App not storing storing infromation and refreshes

The problem is that if you just bind the form to the data source its going to save incomplete information and create duplicate records.  For Patch there are basically two formats you should be aware of

 

Patch(datasource, defaults(datasource), {fieldname: "value", fieldname2: "value", etc}) - This format creates a new record

Patch(datasource, lookup(datasource, field="Value"), {fieldname: "value", fieldname2: "value", etc}) - This format updates an existing record

 

For the update version it will only change the values for which you supply a fieldname: "value" pair.  Existing values will remain unchanged.

 



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

Re: App not storing storing infromation and refreshes

@Pstork1I done that but it doesn't seem to work 

 

This is the formula used;

Patch(WeeklyTimeSheet, Defaults(WeeklyTimeSheet), {Title:ID, Emp_Name:EmpName.Selected, Mon_Activity:MonAct.Selected.Value, Mon_Contract:MonContract.Selected}) 

Also I only tried it on the Monday Screen, how would it work for the other screens?

Highlighted
Dual Super User II
Dual Super User II

Re: App not storing storing infromation and refreshes

As I mentioned, there are two different formats.  The one you used will create a new record.  You can't just use that one formula.  For each screen you'll have to build in logic to call the right Patch() statement based on whether its a new record or an update to an existing record.



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

Re: App not storing storing infromation and refreshes

I don't quite understand what you mean in regards to the update path reference. 

The formula given to update an existing Patch: Patch(datasource, lookup(datasource, field="Value"), {fieldname: "value", fieldname2: "value", etc}) how would I incorporate that. Like you see I'm making a timesheet app and each edit screen represents each day, the first screen which is Monday I used the patch formula given: Patch(datasource, defaults(datasource), {fieldname: "value", fieldname2: "value", etc}). 

So then for the second screen that represents Tuesday, It's the update version on the patch formula I should use, I get that but within the the formula you gave I don't quite understand what should go into  "lookup(datasource, field="Value")"  and once I done this how would this work for the other screens.

 

Here are images of both the Monday and Tuesday Screens:

Screenshot (158).pngScreenshot (157).png

Highlighted
Community Support
Community Support

Re: App not storing storing infromation and refreshes

Hi @SandraAkujobi ,

Have your issue been resolved? If not, happy to help further.

 

I think you should learn more about the Patch function, the second part in Patch formula is BaseRecord that means the record to modify or create. If the record came from a data source, the record is found and modified. If the result of Defaults is used, a record is created.

In Monday, User created a new record, so the second part of Patch function is Defaults(WeeklyTimeSheet).

However, in Tuesday, User need to save the data to the record created in Monday, so use LookUp function to retrieve the record created in Monday as the BaseRecord of Patch formula.

 

Patch(WeeklyTimeSheet, LookUp(WeeklyTimeSheet, Title=ID&& Emp_Name:EmpName), {Tues_Activity:TuesAct.Selected.Value, ...}) 

 Hope this helps.

Sik

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,215)