cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Equivalent of while loop?

Here's the logic i'm trying to achieve in powerapps - however i haven't quite worked it out so here's a bit of psuedocode replicating powerapps as best i can.

 

Set(Old, DataTable1)

If old_date = datepicker.selected:

    UpdateContext({PopUp:false}), Refresh(Table1)

Else:

   WHILE old = DataTable1:

    Refresh(Table1)

UpdateContext({PopUp:false})

 

Mainly the while loop (i can work out the rest - i put it there for context) how would i convert that to powerapps?

11 REPLIES 11
Community Support Team
Community Support Team

Re: Equivalent of while loop?

Hi @Anonymous,

 

I cannot see the difference of these 2 results according to different condition. Both results are refresh table1 and UpdateContext({PopUp:false})?

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nickduxfield
Level 8

Re: Equivalent of while loop?

Are you saying

Set(olddatatable, datatable)

if(old_date in olddatatable.old_date = date.selecteddate, set(olddatatable, datatable),false)

Anonymous
Not applicable

Re: Equivalent of while loop?

Haha yes I can see how that looks!

 

What's going on in the background is a few processes that are changing the excel file it's searching from - flow creates a file which a watcher algorithm detects and then creates a file from some criteria i've set in python etc- the while loop is checking to see if the changes had been made yet.Basically it takes a good old long time for those changes to be made so a while loop is certainly necessary.

 

The first statement simply updates the same table incase there has been changes since the last use, the while command updates the table once it has been modified and re-created.

 

However I believe I have found a solution (if a little long winded!), I'm using a timer to re-state the command every x milliseconds via the repeat function. That has a similar effect to a while, if a little slow. In fact, i added a post in PowerApps ideas (https://powerusers.microsoft.com/t5/PowerApps-Ideas/Add-a-quot-while-quot-statement-into-powerapps/i...) as i think it is a fairly useful command to have that ForAll can't really achieve.

nickduxfield
Level 8

Re: Equivalent of while loop?

your going in directions which ive never been. I'm starting to think that you are Kirk and im spock, and we have just entered into another universe. lol.

However, as you watch til the end everything always becomes clear.

Anonymous
Not applicable

Re: Equivalent of while loop?

I'm flattered @nickduxfield! I'm still fairly new to all this really - perhaps why it's a tad longwinded and lacking conciseness. All i wanted was a 'while' and everything would have been much easier aha 

nickduxfield
Level 8

Re: Equivalent of while loop?

if you are using flow, you could use 'schedule' and a loop. broadcast a message to powerapps or the flow app when the routines are complete. Then the user can refresh.

Anonymous
Not applicable

Re: Equivalent of while loop?

Hm yes that seems like a good idea.. I'm hoping that'll be quicker than the makeshift timer loop i have in powerapps. I'd imagine that'd be the case..

dmcadam1
Level: Powered On

Re: Equivalent of while loop?

Have you tried using a 'do-until' in flows?

 

Where you want

while(old = datetable1)

you could do the reverse in the 'do-until' with the 'until' condition being:

do...
until(old != datetable1)

 

but i may be misunderstanding your issue 

Anonymous
Not applicable

Re: Equivalent of while loop?

@dmcadam1 That could work very well! I  had no idea that was a powerapps command. Would you be able to point me towards the syntax for that-  I'm struggling to find it.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 50 members 3,921 guests
Please welcome our newest community members: