cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ichinova
New Member

Reset SharePoint integrated form

I have a customized SharePoint form and it does not work at all how I think it should. It seems state is persisted across the forms. 

 

If I edit a form, SharePointIntegration.Selected is equal to the selected list item ID. Ok that makes sense. 

 

But when I click New, SharePointIntegration.Selected is still equal to the record I just edited?!

 

There are lots of other oddities. Any variables I configured with Set() maintain their value across records. If I Reset the form previously, then when I open any other record all values are gone. If I populate field A in one form, then go to a new record and save it but leave field A blank, it will get populated at save time with the value from the previous record! 

 

The only way I could see to get around this is to refresh the browser after every action. Is there any way to fix this?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Ichinova 

Please keep in mind that once your PowerApps instantiates itself in your browser session, even if you close it (the customized form), it is not gone.  It will retain its values each time it is opened.  In essence, it is like it is visible and then it is not visible and then it is visible again when needed.  It is not running, then not running, then running again.

 

So you need to account for that.

 

First, what is the Item property of your form?

What is the OnNew and OnEdit and OnSave action of your SharePointIntegration object?

 

It's all about those actions and properties!

_____________________________________________________________________________________
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

3 REPLIES 3
RandyHayes
Super User
Super User

@Ichinova 

Please keep in mind that once your PowerApps instantiates itself in your browser session, even if you close it (the customized form), it is not gone.  It will retain its values each time it is opened.  In essence, it is like it is visible and then it is not visible and then it is visible again when needed.  It is not running, then not running, then running again.

 

So you need to account for that.

 

First, what is the Item property of your form?

What is the OnNew and OnEdit and OnSave action of your SharePointIntegration object?

 

It's all about those actions and properties!

_____________________________________________________________________________________
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

I'm trying to track the mode we are in like this: 

 

OnEdit
Set(Mode, "Edit");
EditForm(SharePointForm1)

OnNew
Set(Mode, "New");
NewForm(SharePointForm1);

OnView
Set(Mode, "View");
ViewForm(SharePointForm1);

OnSave
SubmitForm(SharePointForm1);

 

Then on the Item property for SharePointForm1, I set the property like this:

 

If(Mode = "New",Blank(),SharePointIntegration.Selected)

 

I did some testing with a very simple list and found that the whole issue with the form staying blank after a reset or data being copied over did not happen. So I guess there is something with this app where it is storing those values in a variable or something? I did notice that all variables persisted across instances and on a new form both SharePointIntegration.Selected.ID and SharePointIntegration.SelectedListItemID were set to 1 so you can't really rely on that value exclusively. 

Ichinova
New Member

So this app was making use of a lot of UpdateContext calls to manipulate data in the form fields. Since these values persist from one session to the next, they were overwriting a lot of the field values. The solution was to reset all these variables on edit, view, new and cancel. That meant converting them to global variables first using Set() since you can't call UpdateContext from those events. 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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