cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GarryPope
Impactful Individual
Impactful Individual

Change form to FormMode.View when saving a form

Hello Power Apps Community,

I hope you can help please. 

I have a form called frmTransaction.

The DefaultMode for the form is FormMode.View

I have a pencil icon that's OnSelect property has this formula EditForm(frmTransaction)

I then make a change to the record on the form.
I have a check icon that will save the form. It's OnSelect property has this formula SubmitForm(frmTransaction)
 
What I want to achieve is when I click the check icon the form will submit as above, but then I want to put the form back into FormMode.View

I tried on the check icon's OnSelect property adding this formula SubmitForm(frmTransaction); FormMode.View, but the form constantly stays in FormMode.Edit
 
I read this Microsoft Docs about EditForm, which says "If the SubmitForm function runs when the form is in this mode, a record is changed, not created. FormMode.Edit is the default for the Form control."
 
So my request is: I want the form to be in FormMode.View once I've submitted a form.

If you could suggest anything that would be great.
Garry
1 ACCEPTED SOLUTION

Accepted Solutions
GarryPope
Impactful Individual
Impactful Individual

Hello @rubin_boer and @Eelman,

Thanks for your help with this. I tried everything yesterday, but couldn't get it to do what I wanted. I checked Microsoft's documentation about working with forms, and they suggest having two screens, a Details screen and an Edit screen. On the Details I have the form in "View" mode. On the Edit I have the form in "Edit" mode. 

This works perfectly, so although I have an additional screen to manage, it works. 

Thanks for your help.

Garry

View solution in original post

6 REPLIES 6
rubin_boer
Super User
Super User

hi @gary 

 

try ViewForm(formxxx)

 
Eelman
Super User
Super User

@GarryPope 

In the OnSuccess of your form put this

Set(vLastSubmit, frmTransaction.LastSubmit);
ViewForm(frmTransaction)

Then in the Items of your form you need this:

vLastSubmit

 

Note: It's likely you already have something setup in your Items property and if you do just change my code above wherever you see vLastSubmit to your current Items property.

 

GarryPope
Impactful Individual
Impactful Individual

Hello @rubin_boer,

Thanks so much for the quick reply. This worked, but unfortunately it doesn't show the saved changes to the form.

So if when I first land on the form a field called "Colour" has the value  of "Red".

If I change it to the value  "Blue" when I submit the form, the field "Colour" still shows "Red".

When I navigate away from the screen and then return the Colour value then shows "Blue". 

Thanks very much,

Garry

GarryPope
Impactful Individual
Impactful Individual

Hello @Eelman,

Thanks so much for your help. You were correct, I already had a value in the Item property, which is a variable lclThisTransaction

 

As you suggested for the form's OnSuccess property I put the below:

 

Set(
lclThisTransaction,
frmTransaction.LastSubmit
);
ViewForm(frmTransaction)

 

Unfortunately when I've submitted the form, it doesn't reflect the changes I made. It still shows the form in it's previous state. Could it be that by the time the form has submitted that database (Dataverse for Teams) hasn't updated quick enough to reflect the changes in the form? Maybe I could put a notification message that the change has been made, and then once the notification has been removed it could reset the form? 

 

Thanks,

Garry

GarryPope
Impactful Individual
Impactful Individual

Hello @rubin_boer and @Eelman,

Thanks for your help with this. I tried everything yesterday, but couldn't get it to do what I wanted. I checked Microsoft's documentation about working with forms, and they suggest having two screens, a Details screen and an Edit screen. On the Details I have the form in "View" mode. On the Edit I have the form in "Edit" mode. 

This works perfectly, so although I have an additional screen to manage, it works. 

Thanks for your help.

Garry

View solution in original post

great stuff!!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,078)