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 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:
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at
  • 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,482 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,482 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,482 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

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 Pages

#1
M Bilal Khan Profile Picture

M Bilal Khan 139

#2
Mohsin Ali Profile Picture

Mohsin Ali 41

#3
11manish Profile Picture

11manish 19 Super User 2026 Season 2

Last 30 days Overall leaderboard