web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Run a flow from Model ...
Power Apps
Answered

Run a flow from Model Driven App UI

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

I want to run a flow from a form in a Model Driven App, without installing Ribbon Workbench, 
Can be it be done from a Command, either in PowerFX or JavaScript?

Can it be done on the form save with an event handler?

 

The approach I have seen is to set a set a field on the form and then have a flow with a trigger when an record is modified and a trigger condition expression to check the field updated to trigger value. I have tried this approach and downsides I found were:

1. User gets prompted to save changes when they didn't intentionally change anything.

2. Risk of a recursive loop with the flow updating a record and trigger itself again.

Categories:
  • taku_maru Profile Picture
    35 on at
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    I've made a test for your reference:

    1\Add an "When a HTTP request is received" trigger , save the flow and then copy the URL

    vbofengmsft_7-1658371525219.png

     

    2\Navigate to the model-driven studio to edit command bar

    vbofengmsft_8-1658371525230.png

     

    3\Add a command button 

    vbofengmsft_9-1658371525231.png

     

    I)Action : Run JavaScript

    II)Add Library

    III)Set the Library and then publish the library

    vbofengmsft_10-1658371525221.png

     

     

     

    function BofTest(){
    
    var requestOptions = {
     method: 'POST',
     redirect: 'follow'
    };
    
    fetch("https://prod-24.southeastasiXXXXXXXXnual%2Frun&sv=1.0&sig=VTuTFhOPqu2REZdY9PYJaZVXfHNbrF88guTtfpd-4xc", requestOptions)
     .then(response => response.text())
     .then(result => console.log(result))
     .catch(error => console.log('error', error));
    
    }

     

     

    IIII)Set the function name which we want to run

     

    vbofengmsft_11-1658371525223.png

     

    4\Save and publish the model-driven app

    Click the button in the app and the flow will be triggered

    vbofengmsft_12-1658371525224.png

     

    vbofengmsft_13-1658371525225.png

     

     

    Best Regards,

    Bof

  • Shaheer Ahmad Profile Picture
    2,202 Moderator on at

    Hello, I am facing an issue with this. We are developing a product which will be listed on app source. Apparently when an HTTP Triggered Flow is deployed to another environment it's Webhook URL changes. Therefore we would be unable to trigger the flow through code because the Webhook URL would be static. Is there any way to overcome this? considering the end user doesn't have to check and update the URL in an environment variable or anything. We want it to be totally dynamic. Without end user interaction during deployment.

  • moradaziz Profile Picture
    3 on at

    Thanks a lot.

  • pp365 Profile Picture
    450 Season of Giving Solutions 2025 on at

    Hi everyone, 

     

    I currently have an issue with trying to call a Flow from a Model Driven App and am waiting for a response to my thread on this topic (Initiate Flow from Power FX Menu Button Model Driv... - Power Platform Community (microsoft.com)).

     

    In the meantime I have found this thread. I do not use Javascript. In the solution kindly provided by @v-bofeng-msft , I note this in the code:

     

    fetch("https://prod-24.southeastasiXXXXXXXXnual%2Frun&sv=1.0&sig=VTuTFhOPqu2REZdY9PYJaZVXfHNbrF88guTtfpd-4xc", requestOptions)

     

    What is this URL doing, what should it be replaced with if I try to model this code in my own solution?

     

    Also;

     

    "

    I)Action : Run JavaScript

    II)Add Library

    III)Set the Library and then publish the library"

     

    What is meant by 'Add Library'? Where do I source this, what do I need to customise, where is it stored? How does this interact with 'Set the Library'?

     

    Thank you very much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard