cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hsy
Helper I
Helper I

Asynchronous Function Executing

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?

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @hsy :

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

View solution in original post

3 REPLIES 3
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @hsy ,

Any specific reason to use Collect instead of ClearCollect?

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

v-bofeng-msft
Community Support
Community Support

Hi @hsy :

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

View solution in original post

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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,189)