Skip to main content
Community site session details

Community site session details

Session Id : shoayKfQIgIgEQji8GIVh4
Power Apps - Building Power Apps
Unanswered

If condition multiple statements with ';' delimiter not working anymore?

Like (0) ShareShare
ReportReport
Posted on 23 Jan 2020 23:54:14 by 294

Hello,

 

I have the following if condition for onAddFile property of attachment datacard

 

If(//Check file extension
Last(
Split(
First(DataCardValue71.Attachments).Name,
"."
)
).Result = "docx",
true,
false;Notify(
"Please submit the file in .docx format",
NotificationType.Error
)
)

 

It used to work fine the condition returned false and notified the error message when I uploaded a file type other than docx.

 

Now, when I upload a non .docx file type the condition returns "true" and displays the error notification. If i remove ';' delimeter and notify function next to it... the condition returns false.

 

If replace ';' delimiter with && the condition returns false for non .docx file but the notify function does not trigger(tried other functions too none of them worked).

 

Thanks

Categories:
  • Community Power Platform Member Profile Picture
    on 20 Jun 2020 at 14:15:00
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Hi

     

    I have a concern that why we have to try to give true & false results at Onaddfile when the file always be attached after click OPEN?

    Is there any way to prevent the current file is attached by condition (not reset attachment)

     

    Phu_Le_0-1592662484935.png

     

  • ck25415 Profile Picture
    294 on 28 Jan 2020 at 18:01:25
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Thanks everyone, I split the multiple statements into two separate if conditions.

  • yashag2255 Profile Picture
    24,669 Super User 2024 Season 1 on 25 Jan 2020 at 17:43:06
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Hi @ck25415 

     

    Can you try to setup the configuration like:

    Attachments Control -> OnAddFile -> Set(CheckFileExtension, If(Last(Split(First(DataCardValue71.Attachments).Name, ".")).Result = "docx", true, false))

    If(CheckFileExtension, Patch();Set(), Set();Update())

    The formula presentation should be like this, in case of multiple actions. I am guessing that it is not working because of the Boolean that you passed before the delimiter.

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • CU22081450-0 Profile Picture
    Most Valuable Professional on 24 Jan 2020 at 17:10:48
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Hi @ck25415 ,

     

    Sure.

    Probably your problem is related to use:

    If(condition, true, false;action;action)

     

    Your code tries to receive Boolean values in the first condition ("true") but in the second condition your return Boolean and actions.

    You need to separate each one and you, unfortunately, you expend more than one line of the code.

  • ck25415 Profile Picture
    294 on 24 Jan 2020 at 16:40:26
    Re: If condition multiple statements with ';' delimiter not working anymore?

    @renatoromao 

     

    Set(CheckFileExtension, If(Last(Split(First(DataCardValue71.Attachments).Name, ".")).Result = "docx", true, false)) //your result will be true or false

     

    If(//Check file extension
    CheckFileExtension = false, Notify("Please submit the file in .docx format", NotificationType.Error)) //and ignore if your condition is equals true

     

    I tried above expressions and it worked fine and I thought of using the variable outcome to trigger the notification separately if I cannot execute multiple statements.  The problems comes when I wanted to execute multiple statements in If condition with ';' delimiter. 

     

    I wanted to know if we can use ';' delimiter in If conditions to execute multiple statements, this way I can reduce the number of expressions  I have to write.

     

     

  • ck25415 Profile Picture
    294 on 24 Jan 2020 at 16:32:15
    Re: If condition multiple statements with ';' delimiter not working anymore?

    @v-xida-msft 

     

    Yes, I have set the condition within the OnAddFile property of attachment control. Also, the max number of attachments is set to 1.

     

    I am trying to assign the outcome of the condition to a variable using updatecontext function. So I will need to use true/false in the if condition. 

     

    I wanted to know if we can use ';' delimiter to execute multiple statements in "If" condition in power apps. As I mentioned in my post the condition used to work fine and I am wondering why my expression started to fail now. If we cannot use ';' delimiter to execute multiple statements in "If" condition, what would be an alternative to it ?

  • CU22081450-0 Profile Picture
    Most Valuable Professional on 24 Jan 2020 at 01:30:35
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Hi @ck25415 ,

     

    Did you try this solution below?

    Set(CheckFileExtension, If(Last(Split(First(DataCardValue71.Attachments).Name, ".")).Result = "docx", true, false)) //your result will be true or false

    If(//Check file extension
    CheckFileExtension = false, Notify("Please submit the file in .docx format", NotificationType.Error)) //and ignore if your condition is equals true

  • v-xida-msft Profile Picture
    on 24 Jan 2020 at 01:29:27
    Re: If condition multiple statements with ';' delimiter not working anymore?

    Hi @ck25415 ,

    Do you specify your If condition formula within the OnAddFile property of the Attachments control?

     

    Based on the formula that you mentioned, I think there is something wrong with it. Firstly, I think it is not necessary to specify true or false value within your If formula.

     

    In addition, the Last(Split(First(DataCardValue71.Attachments).Name, ".")).Result formula could only retrieve the file extension of the firstly uploaded file, it would not work for the new uploaded file in your Attachments control.

    I have made a test on my side, please consider take a try with the following workaround:

    Set the OnAddFile property of Attachments control to following:

    If(
     Last(Split(Last(DataCardValue9.Attachments).Name, ".")).Result <> "docx",
     Notify("Please submit the file in .docx format", NotificationType.Error)
    )

    1.JPG

     

    Please consider take a try with above solution, check if the issue is solved.

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete