cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AbubakrWorking
Helper I
Helper I

EditForm with save and ViewForm with Submit Button

Hello Community,
I have created a form that gets data from dataverse table and I have two buttons(Save and Submit). Both buttons submit the form. The thing I want is if the user opens the form again after submitting it through the save button, the form mode should be edit for editing purposes, and if the user opens the form after submitting it through submit button, the form mode should be ViewForm. Any solution to it will be appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @AbubakrWorking 

 

We need to store some value to know what action the user has performed. For example, When the user clicks the Submit button, you need to patch (Update) the one more field to store another value so that form can use that field later on.

  • Submit the form
  • Patch the field (Is Submitted - New custom field)
  • Use that field to allow or deny the form edit

Example of your Submit button. Set OnSelect of the Submit button

Set(SavedRecord,SubmitForm(FormName));
 If(
     IsEmpty(Errors(TableName)),
     Patch(TableName),SavedRecord,{
     prefix_issubmitted:true
     });
     Notify(
         Concat(Errors(TableName), Column&": "&Message),
         NotificationType.Error
     )
 )

Note: In this example field name "prefix_issubmitted"

 

Set the DefaultMode of the form to

If(
    Text(DataCardValue10.Selected.Value) = "Yes",
    FormMode.Edit,
    FormMode.View
)

 

View solution in original post

1 REPLY 1
StalinPonnusamy
Super User
Super User

Hi @AbubakrWorking 

 

We need to store some value to know what action the user has performed. For example, When the user clicks the Submit button, you need to patch (Update) the one more field to store another value so that form can use that field later on.

  • Submit the form
  • Patch the field (Is Submitted - New custom field)
  • Use that field to allow or deny the form edit

Example of your Submit button. Set OnSelect of the Submit button

Set(SavedRecord,SubmitForm(FormName));
 If(
     IsEmpty(Errors(TableName)),
     Patch(TableName),SavedRecord,{
     prefix_issubmitted:true
     });
     Notify(
         Concat(Errors(TableName), Column&": "&Message),
         NotificationType.Error
     )
 )

Note: In this example field name "prefix_issubmitted"

 

Set the DefaultMode of the form to

If(
    Text(DataCardValue10.Selected.Value) = "Yes",
    FormMode.Edit,
    FormMode.View
)

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,555)