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 / Phantom timer trigger ...
Power Apps
Answered

Phantom timer trigger causing unwanted timer runs

(0) ShareShare
ReportReport
Posted on by 367

Guys, I have a real mystery here.

I have a complex canvas app and lots of timers that I use as functions.

In this app I have a form that adds a student to Dataverse (populating 3 different tables with data). The Submit button triggers a sequence of two Timers, addStudent1 and addStudent2

 

Each timer uses a boolean context variable to start it: startAddStudent1 and startAddStudent2, respectively.

 

Generally everything works fine. But there's one weird circumstance where addStudent2 is triggering on its own, causing a bad record to get added to the database.

I've narrowed down the circumstances that cause the phantom trigger--there are 3 fields in the form that check Dataverse for duplicates and notify the user (they all have the same code in their OnChange). But this code never references startAddStudent2.

 

The first time the form detects an existing student in the table, the user can add service, and everything is fine. The second (and subsequent) time the user tries the same thing with a different existing student, addStudent2 triggers immediately.

 

I looked at my variables and startAddStudent2 doesn't appear anywhere unexpected in my app. The duplicate-checking fields don't touch it.

What's more, I made a little debug label to show what happens to my variables when the bug happens:

jzcase_0-1618599970837.png

 

What I discovered is that, when the bug happens, startAddStudent2 never gets set to True. Which means that addStudent2 is triggering independently of its Start condition.

 

Yikes!

 

  • Is it possible for Timers to ever start for reasons other than their Start condition, or the user clicking on them?
  • Are there other debugging tricks I could try to nail down exactly what is happening when my timer triggers?
Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jzcase 

    I would seriously reconsider the concept of using a timer as a function!  If you want a similar and more reliable substitute, you can consider using toggle controls instead.  Put your "function" in the OnCheck of the toggle and set the Default to the variable you are setting.  When the default condition is met the toggle will check and the function will be evaluated.  At the end of the "function" formula, just set your variable back to false, or a condition that will cause the toggle to return to false.

     

    Now, to your existing issue.  Yes, if a timer is set to autostart then it will start on its own.  If it is set to loop it will start on its own.

    You can use the Monitor tool to assess when things are happening in your app.

     

    But overall, a timer should be used to time a duration. 

     

    I hope this is helpful for you.

  • jzimmermancase Profile Picture
    367 on at

    Thank you! That is a good best practice and I will modify accordingly. I've got a couple questions.

     

    1. I turned on debugging, saved and published my app, launched the Monitor, and launched my app. However the Monitor is blank. I leave the monitor one while I close and reopen the app in another window. Nothing. I tried changing the Source Filter from Default to Detailed, and I get some telemetry and logging stuff but nothing else.

     

    2. Just an observation--all of my timers already had their AutoStart and Loop properties set to false.

    3. My addStudent2 timer actually has some justification for being a timer. It has a 5 second duration because there are some housekeeping workflows that do things after addStudent1 completes. Should I leave it as a timer or change it into a toggle and use a different timer to delay it?

  • jzimmermancase Profile Picture
    367 on at

    Just wanted to update to say: Thank you! Replacing all of my timers with toggles did the trick.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jzcase 

    Excellent!  Glad that helped.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard