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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Triggering a Power Aut...
Power Pages
Unanswered

Triggering a Power Automate Flow from a button within an Advanced Form

(0) ShareShare
ReportReport
Posted on by 581

I'm working through an advanced form.

 

I need a button to trigger a Power Automate Flow, and pass through the contact ID of the logged in user to that flow.

 

Is that possible?


Thanks
Lee

Categories:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    Hi, please see if this helps: How to Trigger Power Automate Flow from Power Apps Portals (alphabold.com)

     

  • Lee-Martin Profile Picture
    581 on at

    Thank you @OliverRodrigues that gives me most of what I need.

     

    Is there an easy way to get the current logged in user of the Portal in JavaScript?

  • Lee-Martin Profile Picture
    581 on at

    Also is it possible to get the session ID for the advanced form in the same way?

  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    to get the user ID you can use a mix of Liquid and JS:

    var userId = "{{user.id}}";
    

    the session ID probably the best would be via URL, you can do this via JS or Liquid:

    Liquid --> request.params["sessionid"]

    JS --> 

    var urlParams = new URLSearchParams(window.location.search);
    var sessionId = urlParams.get("sessionid");

  • Lee-Martin Profile Picture
    581 on at

    Thank you

  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    @lee-martin did my previous answer solve your issue? can you mark as the solution ?

    thanks

  • Lee-Martin Profile Picture
    581 on at

     

    I'm using the following code


            //build http request string using URL from Power Automate flow
            var req = new XMLHttpRequest();
            var url = "<<HTTP POST URL HERE>>";

            //send https request to Power Automate
            req.open("POST", url, true);
            req.setRequestHeader('Content-Type', 'application/json');
                     req.setRequestHeader('Access-Control-Allow-Origin', '*');

            req.send(courseupdate);

            alert("updated");


    However I'm now getting a 400 error in my chrome console.


    I've literally lifted most of this from a source that say's it's correct (though I added the Access-Control-Allow-Origin myself)

    Is there a reason why this isn't working?

     

  • Lee-Martin Profile Picture
    581 on at

    Worked out it was an error with the parameter I was passing.

     

    I've put a redirect on the end of it, but it's failing to redirect. Is this more complicated than I'm  trying?

     

    req.send(sendID);

    alert("updated");

    window.location.replace('http://www.bbc.co.uk');
  • Lee-Martin Profile Picture
    581 on at

    Oddly I can now relocate to the bbc website, but if i try a url that's within the portal it flatly ignores what I'm trying to do

  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    can you try:

    window.location.href = "/mypage";

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard