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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Asynchronous Function ...
Power Apps
Answered

Asynchronous Function Executing

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

 

I have a button with the following code

 

RemoveIf(datasource, GUID = Var_GUID);
Collect(datasource, {GUID = Var_GUID, xxxxxx});

 

Basically, it is to remove all the existing records and collect a set of new.

 

The issue I encounter is that second collect function does not always execute as expected,
The thought in my mind is that the first syntax is still being executed then the second started therefore a conflict.

 

Anyone have affirmative mechanism or how to solve it?

Categories:
  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @Anonymous ,

    Any specific reason to use Collect instead of ClearCollect?

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    The formulas separated by ";" in the Canvas app are executed in order. RemoveIF must have been executed before the Collect is executed.

    I suggest you check whether there may be a problem with "{GUID = Var_GUID, xxxxxx}" (for example, whether there are duplicate values in a field that does not allow duplicate values).

    In addition,maybe you could try this formula:

    RemoveIf(datasource, GUID = Var_GUID);
    Refresh(datasource);
    Collect(datasource, {GUID = Var_GUID, xxxxxx});

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Thank you for your reply.

     

    I also noticed that, my previous concern was it is just an order sending to the server.
    While server takes time to execute, the second syntax is excuting before the server finishes.

     

    Now I know the order is executed only when the previous one finishes

  • KeithHo1 Profile Picture
    4 on at

    I found that PowerApps does not wait for the completion of the refresh function before executing the next function. Are there any asynchronous or .then functions available to make the app wait for the refresh? Currently, I'm only using a timer to wait for 3 seconds before refreshing.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard