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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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