I've created a customised power app with an attachment field but when it saves and then I click on New it seems to remember an attachment I uploaded in the very first test item I did. But if I refresh f5 before adding a new one it is blank. Not sure why it is remembering the 1st one I created as that was testing in the app itself on the play mode.
Any ideas on how to make sure when I click New it is a totally blank attachment field it will be appreciated.
To reset only the Attachments field:
1) Make sure the DefaultMode property of the Form is set to New for best results.
2) Create a Button inside the Datacard (to do this, click Insert -> "Button" from top bar while Attachments_DataCard1 is selected or the equivalent in your case) and then set its OnChange to something like Reset(DataCardValue4)
To reset only that field, the Reset cannot be called directly on the DataCardValue4 from outside, or it will throw the runtime error. Must be from inside the DataCard only for resetting only that control.
An easier way is:
B1) Alternative to #2 is to just ResetForm(YourFormName) on the whole Form from a button placed on the Screen (the Button can be placed on any Screen in this case). Use ResetForm to reset the whole form, not Reset, by the way.
Check if it helps @brendenward35
Hi, thank you for the ideas, what I was trying to do is getting it to automatically do this once you click on New and the form opens. At the minute they just do an f5 on the list before clicking new which is similar to your comments I was just wondering if there is anyway for the form to refresh on loading so the attachments field is blanks?
automatically do this once you click on New and the form opens.
Is the New button a button in the Canvas App? If so, you can use the ResetForm(YourFormName) in the OnSelect property of the button, so when the button is clicked, it will blank out the Attachments and any other entries as well.
By "the form opens" please clarify what you mean by this.
If you mean that your Canvas App changes screens mid-form-fill-out, or after it has been filled out and submitted there is some other screen that your App goes to, and you meant you want it to happen when they use some Control to navigate back to the other Form Screen, you can also, use Navigate from whatever other screen back to the Form screen, and use OnVisible property on the screen your form is on and put this Formula in there:
So the form will be blanked out once that Screen becomes visible again e.g. when navigated to from a call to Navigate from a Control on another Screen
Note also that since Forms can be referenced directly from any screen (just like most other Controls), this formula may appear on any appropriate property of a Control or Screen regarding any screen you want, such as the OnSelect of a Button Control - even one residing on a Screen different from the one the Form is on - and it should still reset the specific "YourFormName" Form Control on whichever screen it is on when using ResetForm in this way.
If you also happen to mean you want to switch a Form between editing an existing record and creating a new Record, then use EditForm or NewForm from a Formula to do this kind of switching at runtime
Check if it helps @brendenward35
If I duplicate the form to make a editform or a viewform the field changes for blank to the ecomet document maybe I'm doing something wrong with the form maybe create new displayview and a new editform rather than duplicating the newform?
While we are unsure and we may need to take closer look at what you just provided, note that if you use EditForm or NewForm to switch it back and forth, when it is switched to EditForm, it will use the Item property that is currently there. If this is the issue you may need to change what is there in that Item property, as it may be referencing a Record that was recently edited (this would be by design, unless you change the Item property in some way).
To "change it in some way" one possible approach could be using a Variable and changing it from either the OnReset of the Form (which runs when calling ResetForm) or from elsewhere. For example you could have If(_RecentlyEdited,Blank(),YourRealFormItemHere) for your Form Control's Item property, and then from somewhere else in the App, use Set(_RecentlyEdited,true) so that next time when Form goes to Edit mode again, it will not prepopulate it with the record referenced within YourRealFormItemHere. The moment you wish it would populate YourRealFormItemHere. again the next time EditForm is called, or ResetForm is called, or when otherwise the next time Form goes in Edit mode again in runtime, you could then from somewhere else such as OnReset of that same Form, or from somewhere appropriate, just use Set(_RecentlyEdited,false)
Note that ResetForm sets it back to FormMode.Edit
The ResetForm function resets the contents of a form to their initial values, before the user made any changes. If the form is in FormMode.New mode, the form is reset to FormMode.Edit mode. The OnReset behavior of the form control also runs. You can also reset individual controls with the Reset function but only from within the form.
If the Item property references a real record then it will remember what is there even after using ResetForm, and maybe especially if you use ResetForm while the Form was previously in the FormMode.New mode - is this what you describe as the issue?
If so, try paying attention to the Form Control's Item property and see if you could adjust it in some way so that it behaves how you want it to.
See if it helps @brendenward35
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.