cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ck25415
Level 8

Avoid clearing the data in form after submitting data using Patch

Hello,

 

I have declared a variable on screen visible using Set(currentRecord, Defaults('datasource')), datasource is a sharepoint list.

I have a  timercontrol on the same screen with onTimerEnd set to Set(currentRecord,Patch('datsource',currentRecord,EditForm1_MemberSubmission1.Updates,EditForm1_MemberSubmission2.Updates)). The two editforms are on two different screens. After submitting the data to sharepoint list, the text in the fields is cleared which I am trying to avoid so that user can continue to see the submitted text.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Avoid clearing the data in form after submitting data using Patch

Hi @ck25415,

 

Could you please share a screenshot of your app's configuration?

Further, could you please show more details about the Timer control within your app?

 

I have made a test on my side (using a Button control instead of a Timer control), and don't have the issue that you mentioned. The GIF screenshot as below:Test1.gif

 

 

Please check if you have reset the Edit forms within your app using ResetForm function after you submitted the data. 

 

In addition, please take a try to add a Button control within your app instead of the Timer control to submit the form data, then set the OnSelect property of the Button control to following formula:

Set(currentRecord,Patch('datsource',currentRecord,EditForm1_MemberSubmission1.Updates,EditForm1_MemberSubmission2.Updates))

then check if the issue is solved.

 

Please also check if the Item property of the Edit forms set to the currentRecord variable, if yes, please remove the currentRecord variable from the Item property of the Edit forms (Remain empty within the Item property of the Edit form control). 

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
nickduxfield
Level 8

Re: Avoid clearing the data in form after submitting data using Patch

Check your gallery to ensure any filters don't filter out on success.
Check the on success property of the form to ensure it doesn't reset form.
Check the form reset property.
You need to set global variables on App start.
Use the on success property of your form to capture last submit with form.lastsubmit.field.

Some ideas...
nickduxfield
Level 8

Re: Avoid clearing the data in form after submitting data using Patch

Apologies, are u using the form, or a form you created?
If so,
You can make use of a tempcollection.of preferably on app start collect(tempcollection, first(source().
Put a switch on new, or edit or view button.
New, set defaults,
Edit, patch(tempcollection,first(tempcollection),this item) or clear collect.
On submit, if new, collect(source, first(tempcollection))
If edit, patch(source, from tempcollection)
Set defaults on all fields to first(tempcollection).field1

Ask if needed
ck25415
Level 8

Re: Avoid clearing the data in form after submitting data using Patch

Hello Nick,

 

I am using the editform(defualt set to new) which loads with the screen(not creating a new item from the screen). I checked the onsuccess and reset properties which was set to false. I did not quite understand the tempcollection you explained, could you please explain it more.

 

Thanks much,

nickduxfield
Level 8

Re: Avoid clearing the data in form after submitting data using Patch

 

@xample@ck2541

If I understand now,

You have the form with datacard OODB, and you havent created a your own with controls. Reading your history, you were using patch for unique fields which led me off track.

Regarding your choice of default form mode of NEW, is this on purpose?

If so, I can deduce the following:

The form item property is usually paired to a gallery as gallery.selected, if you select an item in the gallery to edit and submit the form, it will still show gallery.selected and the fields will be populated.

However, if you have the mode set to NEW form, gallery.selected is ommitted because its not in the gallery yet, and therefore the form will be empty on submit.

 

My next thoughts are, your default form mode of NEW.

Other thoughts are, do you just want to see the last submit? Or use the last submit in the populated fields on the next submit?

 

To get around this you might want to try, creating a temp collection.

Try to collect the last(Source) into a collection with the aim of only 1 record.

A few methods:

  1. For the submit button, patch to this temp collection as in First(Tempcollection,{Form.Lastsubmit....}), or similar.Then for the default / update for each datacard depending on what the reason for the Default as a NEW form is, set to the First(tempcollection).field.
  2. On Success of the form, patch to this temp collection as in First(Tempcollection,{Form.Lastsubmit....}. Then put in the item property of the form First(Tempcollection)

Example: Title: First(Tempcollection).Title

This will ensure you will always see the last submit, and if it fails, you will have a draft.

When you go to edit, ClearCollect(tempcollection,thisitem) or similar. If new, you can also decide defaults etc.

 

If im off track let me know.

I prefer to use minimal variables in all my solutions. My default option is to use collections where possible be cause you can easily modify collections as apposed to variables.

Community Support Team
Community Support Team

Re: Avoid clearing the data in form after submitting data using Patch

Hi @ck25415,

 

Could you please share a screenshot of your app's configuration?

Further, could you please show more details about the Timer control within your app?

 

I have made a test on my side (using a Button control instead of a Timer control), and don't have the issue that you mentioned. The GIF screenshot as below:Test1.gif

 

 

Please check if you have reset the Edit forms within your app using ResetForm function after you submitted the data. 

 

In addition, please take a try to add a Button control within your app instead of the Timer control to submit the form data, then set the OnSelect property of the Button control to following formula:

Set(currentRecord,Patch('datsource',currentRecord,EditForm1_MemberSubmission1.Updates,EditForm1_MemberSubmission2.Updates))

then check if the issue is solved.

 

Please also check if the Item property of the Edit forms set to the currentRecord variable, if yes, please remove the currentRecord variable from the Item property of the Edit forms (Remain empty within the Item property of the Edit form control). 

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 178 members 4,735 guests
Please welcome our newest community members: