cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EmMa73
Frequent Visitor

Problem with two sequencial patch

Hello everyone

I have a trigger that patches two different lists in SharePoint.

The second patch uses the data entered/updated by the first patch.

Sometimes (due to network problems?) the second patch retrieve old list data (not yet patched by the first patch). 

It seems that the second patch fires before the first one ends....

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
EmMa73
Frequent Visitor

I did many tests and it seems to work call the first patch inside the collection.

It seems like PowerApps waiting for the collection to be built before moving on to the next action, but I'm not sure. Maybe today the network was simply faster

Any way, it would be nice to have in PowerApps a function like Wait...Until

View solution in original post

6 REPLIES 6
poweractivate
Community Champion
Community Champion

@EmMa73 You'll need to check for stale data in this case.

You may need to have something in the first Patch that the second patch knows that it has been patched - maybe even a dedicated column for this purpose whose value is always set to "Patch1" or something like that when first patch was successful.

For the Second Patch, use it inside a Timer which will retry on say 1 second intervals and have formula OnTimerEnd and repeat set to true, and duration of 1000 (milliseconds) - if the data uniquely identifying First Patch success e.g. "Patch1" cannot be found in that column, then it must retry this patch again for a few times until it is found.

After a max number of times, it should just stop and show some error instead.

If the second patch go through it should not take out "Patch1" from that column altogether.

In similar vein, if Patch1 should not even happen if another concurrent Patch1 was done but not Patch2 yet, then this can be checked as well to avoid another kind of inconsistency as well.

 

The above sound kind of hard I know, but it is only way I know of to be sure.

If someone else have simpler idea, I welcome it, please reply as I would like to know if it to keep in mind as well.

poweractivate
Community Champion
Community Champion

@EmMa73 Besides the idea I have another one. You can force it so user input is required. If first patch doesn't go through by network problem, you never proceed to the next step to begin with. This next step could be another screen with another button to put more input inside of it and then to press it for the second patch. 

 

If it is not acceptable for the First Patch to happen without the Second Patch or vice versa, I guess the hard way might be best. It might be necessary to be able to undo the Patch too. You may need to go so far as to make a little bit of custom transaction log where you can roll and unroll the sequence. If an operation to edit was made, and not another one, eventually the first one may lock up on purpose and not allow further edit. After a max tie, it will unroll the operation and go back to how it was before to avoid stale or intermediate states (maybe this can be done with a Recurrence Flow from Power Automate) - the harder idea I put originally is sort of like this - except it will just lock in that version and never reset either. 

 

Also instead of making them in sequence try to just nest the Patches - maybe this just works too (careful though - I wouldn't do it this way - this is in case to consider if it works for you as workaround for some reason and in some specific way).

Hi @poweractivate ,

the second solution does not solve my requirements (user input is required only on the first patch).

I have to think if the first solution is possible..... I will let you know.

 

Do you know if inserting the patch in a collection solves the problem? Is it true that powerapps moves to the next action only if the collection has been built?

 

I would try this:

 

ClearCollect(firstpatch, Patch (first list, ...));

//second patch

Patch (second list, ....);

@EmMa73 You could definitely try that as well, maybe it will work.

Go ahead and try it.

The problem is, I really am not sure that  it will be different from before though, but you could give it a try.

I suspect you will get the same problem though.

@poweractivate 

I will try because if it worked it is much easier.

 

Unfortunately it is difficult to do a test because the problem does not always happen but (perhaps) only when network is very slow.

EmMa73
Frequent Visitor

I did many tests and it seems to work call the first patch inside the collection.

It seems like PowerApps waiting for the collection to be built before moving on to the next action, but I'm not sure. Maybe today the network was simply faster

Any way, it would be nice to have in PowerApps a function like Wait...Until

View solution in original post

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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