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 / How to handle asynchro...
Power Apps
Answered

How to handle asynchronous execution in PowerApps when using timers as function calls?

(1) ShareShare
ReportReport
Posted on by 37

-------------------------------------------------------------------------------------

Edit: I sincerely apologize for my lack of knowledge in this area.

  • I now understand that user-defined functions (UDFs) do exist in PowerApps, but they appear as "experimental" features, and it is recommended not to use them in production.
  • When one button's OnSelect event triggers another button's OnSelect, the execution is asynchronous, meaning the original event does not wait for the called event to complete before continuing. Same on timers.
  • I will further explore Custom Canvas Components as a better alternative.

Thank you for your patience and for pointing me in the right direction!

------------------------------------------------------------------------------------
 
I'm using PowerApps, where there's no native support for user-defined functions (. To work around this, I simulate function calls using the OnTimerEnd event of a Timer control. The approach is as follows:
  • I place the logic of my "function" inside the OnTimerEnd event of a Timer (myTimer).
  • To "call" this function, I start the Timer with myTimer.Start, which triggers OnTimerEnd after a very short duration (e.g., 1ms).
This works, but the problem is that 'OnTimerEnd' executes asynchronously. If I trigger multiple functions in sequence, they may execute out of order or interfere with each other.
 
I know that user-defined functions exist in experimental mode, but since they are not recommended for production use, I'm looking for a reliable alternative.
 
Question:

How can I ensure that the execution of these simulated functions is completed before proceeding to the next step? Is there any way to "await" or synchronize these calls in PowerApps?

Any insights or best practices to handle this kind of asynchronous behavior would be greatly appreciated!

Categories:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,433 Super User 2025 Season 2 on at
    Hi
     
    This statement is not true, I'm using PowerApps, where there's no native support for user-defined functions, you should fire whomever trained you and told you that.
     
    User defined functions and the ability to call code in a Synchronous way has existed for years.
     
    If you searched you would have found many, but here are some options.
    But please, do some more research and please don't just make statements that will confuse others.
     
    1. You can put Any control on the screen that has an OnSelect. You can add whatever code you want to run. You can then make it invisible. From any other code please on that screen, you can call the Select function on the control...
     
    It will act just like a User Defined Function
     
    Button1 is invisible
    In the OnSelect you put code in it
     
    Button2 has multiple lines of code including calling Button1s OnSelect, using Select(control), which has your code and is in the middle of Button1s total call. It will be Synchronous
     
     
    Example: Button 1
     
    Set(a, "Line1");
    Set(b, "Line2");
    Select(Button2);
    Set(c, "Line3");
     
     
    2. You can create custom Canvas App components, as part of your solution and directly in the App, NOT a coded component. It will let you create many different styles of functions and actions
     
    These would have you create the custom component, drop it on the screen, it can even be invisible. DO the same thing as the first example.

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