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

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
Highlighted
Power Apps
Power Apps

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

5 REPLIES 5
Highlighted
Power Apps
Power Apps

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

Highlighted

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

Highlighted
Frequent Visitor

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

Highlighted
Advocate I
Advocate I

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

 

Highlighted

If you use , between arguments in your formula, then ; is used to separate different statements. If ; is used between arguments, then ;; is used to separate statements. It has to do with local settings. , & ; = American. I have Dutch setting an need to use ; & ;; .

I hope that clarifies this issue.

 

P.S. 

 

Good to remember this when you find code snippets on the net. Can be the difference between working code and "angry" code

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,790)