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

Autosave with timer control with loop enabled

Hello,

 

I have screen1, screen2. I have a timer control on screen2 set to 60 seconds with repeat turned on. Ontimer end is set to Patch('datasource', Defaults('datsource'), EditForm1.Updates, EditForm2.Updates) and I also have a submit button on screen2 which kicks of a flow and also submits the item to sharepoint using the same patch function. Since trepeat is turned on, I see multiple entries created in sharepoint list and also final submit creates on more entry. 

 

Is it possible to save everything in one sharepoint list item without multiple entries?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Autosave with timer control with loop enabled

When you have `Defaults(datasourcename)` as the second parameter of the Patch function, it will always create a new record - which is why you're seeing many new records in your list.

 

If you want to have only one record auto-submitted (via the timer), you can store the current record to be stored in a variable, whose initial value would be `Defaults(datasourcename)` - so that the first time it will create a new record. But afterwards, you need to have that record that was created, so you'll be updating that record instead of creating a new one.

 

For example, in the OnVisible property of the first screen you can have the following expression:

Set(currentRecord, Defaults(datasourcename))

In the timer end, you can patch the current record - and update the current record with the result of Patch.

Set(
    currentRecord,
    Patch(
        datasourcename,
        currentRecord,
        EditForm1.Updates,
        EditForm2.Updates))

 

View solution in original post

5 REPLIES 5
Highlighted
Power Apps
Power Apps

Re: Autosave with timer control with loop enabled

When you have `Defaults(datasourcename)` as the second parameter of the Patch function, it will always create a new record - which is why you're seeing many new records in your list.

 

If you want to have only one record auto-submitted (via the timer), you can store the current record to be stored in a variable, whose initial value would be `Defaults(datasourcename)` - so that the first time it will create a new record. But afterwards, you need to have that record that was created, so you'll be updating that record instead of creating a new one.

 

For example, in the OnVisible property of the first screen you can have the following expression:

Set(currentRecord, Defaults(datasourcename))

In the timer end, you can patch the current record - and update the current record with the result of Patch.

Set(
    currentRecord,
    Patch(
        datasourcename,
        currentRecord,
        EditForm1.Updates,
        EditForm2.Updates))

 

View solution in original post

Highlighted
Post Patron
Post Patron

Re: Autosave with timer control with loop enabled

Hello @CarlosFigueira,

 

Thank you, that worked but whenever the timer ends after submitting the data to the sharepoint list its also clearing the existing text in the powerapps. Is there way to continue from the last word entered in the text field.

Highlighted
Power Apps
Power Apps

Re: Autosave with timer control with loop enabled

Not if you're using forms; when you use a form, and a data source is updated (i.e., in a Patch operation), then the form will take the result of the operation and make any updates that the server has - and will reset its fields to take those values.

 

You may be able to go avoid using forms (for an example, see this blog post by @Meneghino), but you will need to handle the updates yourself. You can also have several "checkpoints" where the user will initiate a save (Patch) operation, instead on relying on a timer to do that on the user's behalf.

Highlighted
Post Patron
Post Patron

Re: Autosave with timer control with loop enabled

Hello Carlos,

By setting the item property of the form to empty(i.e nothing in the field) I was able to see the previous saved text and was able to make further changes to text and update the item in SharePoint. Do you think that the method suggested by you in the blog is better way to deal this problem, please suggest.
Highlighted
Power Apps
Power Apps

Re: Autosave with timer control with loop enabled

I haven't tried setting the Item in the form to empty, so if it works for you, then great. The blog post gives you more control over the layout / data, with the drawback that you need to handle the changes yourself.

 

Remember, however, that many times you do want to get the updated item from the server after a Patch operation (when someone else edited the item, if there are any server-generated columns, etc), so ignoring the result from the server (which you will do if you set the item to blank) may lead to hard-to-find problems.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published 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,712)