Saturday, July 4, 2020

Calling power automate in portals



Calling Power automate  from portal

In this post , we will see about how to call the power automate by clicking button from portal.

Create web page
Go localize content of web page
Paste the below content in copy(HTML) section

<h1>Send an Email</h1>

<form action="/action_page.php">
  Subject: <input type="text" id="subject" name="subject" size="100" maxlength="100px"><br><br>
  Message: <textarea id="message" name="message" rows="4" cols="100"></textarea><br><br>
  <button id="sendemailbtn" onclick="Sendmail()" type="button" class="btn btn-primary button" style="margin-center:10px;"><span></span>Send Email</button>
</form>
<div>
    {% raw %}
    <script type="text/javascript" language="javascript">
   
     function Sendmail(){
         var subjectval = document.getElementById("subject").value;
         var messageval = document.getElementById("message").value;
        
    parent.$.ajax
    ({
        type: "POST",
        url: "https://prod-47.westus.logic.azure.com:443/workflows/47d1962b0cdd4b0fba8a8aa44622d49e/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=cqkmZaBfh1P92dYRy4_4Eu5af8u8kzYn5Ox_kmAEk-o",
        contentType: 'application/json',
        data: JSON.stringify({"subject" : subjectval , "message" : messageval}),
        success: function ()
        {

            alert("Email sent successfully");
                                    
        }
    });
     }
    </script>
    {% endraw %}
</div>









To call power automate on html button click

Need to give the portal url http request in javascript

 




Click on sample payload and type {“subject” : “test” , “message” : “test”}