Forum Discussion

jordancnolan's avatar
jordancnolan
Copper Contributor
Mar 23, 2024

Clear a variable when a custom SharePoint libary form closes

I customized one of my lists forms with PowerApps.  One of the things I wanted was for a user to be able to continue to work on the form when they pressed the Save button.  This would cause the form to go back to record 1 in the list, but I got around that by setting a variable to capture the new record in a variable.

 

Set(MyVariable, SharePointForm1.LastSubmit)
 
Then I set the form Item property to:
 
If(IsBlank(MyVariable),SharePointIntegration.Selected,MyVariable)
 
This works well, except for when I click off the form and go back to the list.  When I click the list item, the form opens to the last MyVariable record instead of the list item I selected.  I have to click the list item, close it, then click it again to get to the record I want.
 
I know the issue is because MyVariable is not being cleared when I click the X on the form and I know that the form itself does not really unload.  I have a button on the form that has the code:
 
Set(MyVariable, Blank()) 
 
And this makes the form work perfectly, but I do not want to have users clicking the button to fix this issue.  I can't seen to find a property on the Form or Screen where I can put this Set command

2 Replies

  • jordancnolan 

     

    Try setting below formula for all these properties:

    • SharePointIntegration.OnView
    • SharePointIntegration.OnEdit
    • SharePointIntegration.OnNew

     

    Set(MyVariable, Blank())

     


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • jordancnolan's avatar
      jordancnolan
      Copper Contributor

      ganeshsanap 

       

      Thanks for the tip, but OnEdit will not work for me because the user brings up the wrong record in the View. OnNew does not matter since it is bringing up a new record.

       

      The issue I am having with the OnView opiton is that the form does not really unload in the background unless I refresh the page.  So if the user mistakenly clicks off the form to the list and clicks another item, they variable does not have the option to update.

       

Resources