web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issue with variable re...
Power Apps
Answered

Issue with variable reset in power apps

(0) ShareShare
ReportReport
Posted on by 7
I have a SharePoint page where employees record the start and stop times for each operation in a work order. I’m trying to create a user-friendly form in Power Apps to streamline this process. The form needs to be reopened multiple times to log times for different operations.
 
I’ve added a button that populates the current time when clicked, and each time entry is managed using variables. For example, the variable op1start is initialized as empty ("") in the OnVisible property of the screen (formscreen1) and updates with the current time when the button is clicked. The time fields use this formula:
If(MaskStop = "", Right(Left(Parent.Default, 5), 2), Text(Minute(Now()), "00")).
 
This works perfectly the first time the form is opened. However, after closing and reopening the form using the "NEW" button, the variables don’t reset. As a result, the time fields are prefilled with the last session's data instead of resetting to blank. I’ve tried resetting the variables using Set(Var, "") and using ResetForm(formscreen1) in the OnSave, OnNew, OnSuccess, and OnVisible properties, but nothing seems to resolve the issue.
 
Is there something about Power Apps forms that could be causing this behavior? How can I ensure the variables reset properly each time the form is reopened?
I have the same question (0)
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    I assume this is a SharePoint integrated form ? If so, the behaviour is unfortunately exactly as designed - when an integrated form is closed, for performance reasons, it uses the RequestHide() command and as the name suggests is simply hidden waiting for next record/action to be chosen, when the only value that is updated is SharePointIntegrated.Selected (the current record selected and this is updated on the Form, which is already open. Unless the user refreshes their browser between every record/action, neither OnStart nor Screen OnVisible runs, hence the Variable does not get set/reset. You can try putting the Variable reset OnNew and OnEdit, but this may not work.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps   
  • Verified answer
    Rayon Robert Profile Picture
    20 on at
     
    I tested your scenario and found a working solution with some adjustments to the properties:
    1. On the 'New Form' button:
    NewForm(Form1);
    Set(op1start, Now());
    Set(op1stop, Blank());
    
    2. On the 'Submit Form' button:
    Set(op1stop, Now());
    SubmitForm(Form1);
    ResetForm(Form1);
    Set(op1start, Blank());
    Set(op1stop, Blank());
    
    3. On the fields recording time, I set the following on 'Default':
    Start Time:
    Text(op1start, "dd/mmm/yy hh:mm:ss")
    Stop Time:
    Text(op1stop, "dd/mmm/yy hh:mm:ss")
    Here's an output of my test based on the above.
    Feel free to test and let me know how this works.

    Please click Does this answer your question if my post helped you solve your issue.
  • CU06121832-0 Profile Picture
    7 on at
    Thank you for your step  by step answer! I followed the same and it worked perfectly. Thanks for your help in resolving this. Much appreciated 😊 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard