cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
saleksanyan
Frequent Visitor

Reflecting form's changes after data has been updated

Hi All,

Having trouble with my forms not updating. Here is the scenario:

On a previous screen, a record is selected via a Combobox (LComboBox1) and the user clicks "View Details."

ViewDetails OnSelect: Set(FormActionVar, FormMode.View); Navigate(FView).

FView contains a form (FViewForm) which shows contract data. Relevant properties of FViewForm:

DataSource: BidContract (List on SP)
Item: LComboBox1.Selected
Form mode: FormActionVar

 

User can now click an Edit button ( set(FormActionVar,FormMode.Edit) - I did this rather than EditForm because I also use the variable to show/hide the save and discard changes button)

 

User can make changes to the form, then click Save. The desired behavior is for it to submit the changes, notify the user of a success, change the form back to View, and show the updated values. Here is my Save's button OnSelect:

 

 

SubmitForm(FViewForm);

If(
	IsEmpty(Errors(BidContract)),
	Notify("Changes saved successfully.", NotificationType.Success
	);
	Set(FormActionVar, FormMode.View); ResetForm(FViewForm),
	Notify(
		First(Errors(BidContract)).Message,
		NotificationType.Error
	)
)
	

 

 

However, that does not work. I even tried it with a Patch function:

 

Set(varPatch,LComboBox1.Selected);
Patch(BidContract, varPatch, FViewForm.Updates)
If(
    IsEmpty(Errors(BidContract)),
    Notify(
        "Successfully Saved!", NotificationType.Success
    ); Set(FormActionVar,FormMode.View);ResetForm(FViewForm),
    Notify(
        First(Errors(BidContract)).Message,
        NotificationType.Error
    )
)

 

 

I have tried to include a Refresh of BidContract, but I am not sure where to insert it.

 

Has anyone found a good solution for this issue?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Drrickryp
Super User
Super User

@saleksanyan 

Don't put anything other than SubmitForm() in the button. The rest should be in the OnSuccess property of the form itself.

You don't want to execute those commands until the data is successfully submitted.

View solution in original post

@saleksanyan 

As @Drrickryp has mentioned, most of your formula should be in the OnSuccess and OnFailure of the form.  Your submit action should simply be SubmitForm(FViewForm)

 

In your OnSuccess you should have:

Notify("Changes saved successfully.", NotificationType.Success);
ViewForm(FViewForm)

In your OnFailure you should have nothing really as the form will have already shown the errors that were encountered.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
Bilakanti
Responsive Resident
Responsive Resident

Hi @saleksanyan ,

 

Can you please elaborate more on what is the error. Is the data not pushing into SharePoint list or you are unable to see notifications either success or failure?

Drrickryp
Super User
Super User

@saleksanyan 

Don't put anything other than SubmitForm() in the button. The rest should be in the OnSuccess property of the form itself.

You don't want to execute those commands until the data is successfully submitted.

View solution in original post

Thanks - forgot to clear this up.

The data is actually correctly going into the sharepoint list. Once the form goes back into View, the values revert to the old ones.

Hi @saleksanyan ,

 

Can you remove ResetForm(FViewForm).

Once the submit form is done, you are setting back the form mode to view. That should be fine.

@saleksanyan 

As @Drrickryp has mentioned, most of your formula should be in the OnSuccess and OnFailure of the form.  Your submit action should simply be SubmitForm(FViewForm)

 

In your OnSuccess you should have:

Notify("Changes saved successfully.", NotificationType.Success);
ViewForm(FViewForm)

In your OnFailure you should have nothing really as the form will have already shown the errors that were encountered.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Got it - made that change. Now, another question:

Some of the form's values drive a gallery. When I update those values, the gallery does not update, even if OnSuccess has Reset(Gallery). Anything that can be done there?

RandyHayes
Super User
Super User

@saleksanyan 

Reset(Gallery) will do nothing - remove it.

What is the Items property of your Gallery?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Gallery's Datasource is a different file called VendData. The Form has keys for vendors (V1, V2,... V10) that indicate which vendors are associated with a contract. The VxID is the data card of the actual form, which updates correctly - but the gallery does not refresh until I go out and back in. I also tried to have the OnVisible perform a Refresh(VendData), but that didn't do anything.

 

Gallery's Items is expressed as follows:

 

 

 

Filter(
    VendData,
    IVID = V1DC.Text Or IVID = V2DC.Text Or IVID = V3DC.Text Or IVID = V4DC.Text Or IVID = V5DC.Text Or IVID = V6DC.Text Or IVID = V7DC.Text Or IVID = V8DC.Text Or IVID = V9DC.Text Or IVID = VADC.Text
)

 

 

 

RandyHayes
Super User
Super User

@saleksanyan 

It's a bit hard to visualize.

So, some questions for clarity:

1) Your Gallery is based on VendData with is a list DataSource in SharePoint?

2) Your Form is based on the BidContract list which is used in the Items property of the LComboBox1 - what is that Items formula?

3) What are these?  V1DC, V2DC....VADC And where are they?  You mention they are in your form?

 

I'm trying to establish the connection of your Gallery items to what you are submitting.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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,323)