Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

How to use Launch function in an If

Posted on by 4
I am generating a pdf with a flow in power automate this returns me a link to download the pdf but I can not get the Launch function to run inside the if, it only works on a button?
 
If(
    !IsBlank(pdfLink);
    Notify("El PDF ha sido generado ya puedes descargarlo!"; NotificationType.Success);
    Launch("https://cepucmmedu.sharepoint.com/teams/PasantasEICT609" & pdfLink)
);;
Categories:
  • Mark Nanneman Profile Picture
    Mark Nanneman 329 on at
    How to use Launch function in an If
    Strange...  It is possible for me to use the Launch within an If() function.  I was able to basically put your formula verbatim into my power app, just changing the syntax for English and it worked.

    If you remove the "Notify" action does it work?

    I'm glad you found a work around though!
     
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 1,278 on at
    How to use Launch function in an If
    Instead of directly using Launch inside the If, you can manage it with a variable and a separate button or function call.
    If(
        !IsBlank(pdfLink),
        Notify("El PDF ha sido generado, ya puedes descargarlo!", NotificationType.Success);
        Set(varPdfLink, "https://cepucmmedu.sharepoint.com/teams/PasantasEICT609" & pdfLink)
    )
     
    OnSelect property:
    If(!IsBlank(varPdfLink), Launch(varPdfLink))
     
    you can call the Launch function conditionally using a timer component:
    Start = !IsBlank(varPdfLink)
     
    Use the OnTimerEnd property to trigger the Launch
    If(!IsBlank(varPdfLink), Launch(varPdfLink))
     
  • AG-15111838-0 Profile Picture
    AG-15111838-0 4 on at
    How to use Launch function in an If
    You are right Mark Nanneman, it is because of my language that the syntax is a little different, when you use a , I must use ; and when you use ; I use ;;

    The if works for me, what I can't achieve is to open immediately the new tab with the link as you say. Surely it is because of what @SpongeYe says, it is not possible and what I am looking for is not to have 2 buttons in the gallery, one to trigger the flow that generates the pdf and another to launch the link and download it.
     
  • Mark Nanneman Profile Picture
    Mark Nanneman 329 on at
    How to use Launch function in an If
    The formula appears to have a syntax issue, unless things are different in your language/region.  

    For me to get this function to work, I'd have to write it like the following (with a comma after the first If() condition.
    Also, I had to add commas for the Notify() function, to set the type and timeout.


    And I did test it and it did work--however if you don't set a long enough duration on the notification, you will never see it.  It immediately pops you over to the new tab w/ the link.

    If you want to force the user to see the notification message, put it in a popup container that is normally hidden, and use your formula to toggle the visibility of the popup component, and have a button there that Launches the link.
    ​​​​​​​
    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  | Buy me a coffee
  • Suggested answer
    SpongYe Profile Picture
    SpongYe 5,198 on at
    How to use Launch function in an If
    Hello, 
     
    Launch can only be used in behavior formulas. Launch and Param functions
    By selecting a Button control, the user initiates a sequence of actions, or behaviors, that will change the state of the app.
    Because these functions change the state of the app, they can't be automatically recalculated. You can use them in the formulas for the OnSelect, OnVisible, OnHidden, and other On... properties, which are called behavior formulas.
     
    Hope this helps.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard