cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GN
Level: Powered On

Multiple statements in IF-TRUE branch

in another message I read that

you can chain multiple functions in a true case of an if by using ";" as delimiter.

 

but on my locale, ";" is the default delimiter. which delimiter could I use then to get multiple statements executed for an if-true branch?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Multiple statements in IF-TRUE branch

You'd use the ';;' character pair to separate multiple statements, something along the lines of the expression below:

If(
    TextInput1.Text = "";
    Set(isEmpty, true);; Set(isError, true);; Set(another: 123);
    Set(isEmpty, false);; SubmitForm(EditForm1))

View solution in original post

4 REPLIES 4
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Multiple statements in IF-TRUE branch

You'd use the ';;' character pair to separate multiple statements, something along the lines of the expression below:

If(
    TextInput1.Text = "";
    Set(isEmpty, true);; Set(isError, true);; Set(another: 123);
    Set(isEmpty, false);; SubmitForm(EditForm1))

View solution in original post

sscarcella
Level 8

Re: Multiple statements in IF-TRUE branch

is this for real?  I cannot get ;; to work at all.

GN
Level: Powered On

Re: Multiple statements in IF-TRUE branch

yes. maybe you have a different locale? then "," is your thing.

MrsNaniPenny
Level: Powered On

Re: Multiple statements in IF-TRUE branch

Hi

 

I have tried both ,, and ;; and they do not work. Upon further investigation I found that && does the trick.

 

You are, however, not allowed to do certain actions together, for example, you cannot do anything with collections, like a ClearCollect AND something else.   If you do, you'll get an error, which basically indicates what only certain actions can be chained together. Setting variables, refresing data sources, etc. seem to work fine with the && operator. I have not tried all other action combinations, so do not have a definitive list, so you'll have to try and see what works.

 

See this example that I use in one of my apps. It updates an image data source, puts the images in a collection and then sets the image variable.

 

If(currentImageID = LastImageID, Refresh(Images)); //do this if true
If(currentImageID = LastImageID,ClearCollect(colImages, Images));  //do this if true
If(currentImageID = LastImageID,
    Set(currentImageID, First(colImages).ID) //do this if true
       && Set(LastImageID, Last(colImages).ID), //and this if true
    Set(currentImageID,currentImageID+1)) //else if false

 

If I had not had the need to put the images in a collection, the statement would have looked like this:

If(currentImageID = LastImageID,

    Refresh(Images//do this if true
       && Set(currentImageID, First(colImages).ID) //and do this if true
       && Set(LastImageID, Last(colImages).ID), //and do this if true
    Set(currentImageID,currentImageID+1)) //else do this if false

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 417 members 5,549 guests
Please welcome our newest community members: