Trigger a MS Flow Using jQueryuery/JavaScript:
To trigger an MS Flow first we need to create an workflow. Next we need to obtain its URL for triggering it. In below example, we are starting a workflow which is taking email address, email subject and email body as parameter and sending mail to email of related user.
//This function triggers the microsoft flow
function beginMSFlow() {
var httpPostUrl = "obtain URL from MS flow";
var postData = {
emailadress:'raju@testdev.com', // Object keys must be similar as you used in the MS flow
emailSubject:'Testing Raju',
emailBody:'Hello User\n Welcome, You just trigger a MS Flow'
};
$.ajax({
url: httpPostUrl,
method: "POST",
crossDomain:true,
async:false,
processData:false,
headers: {
"content-type": "application/json",
"cache-control": "no-cache"
},
data: JSON.stringify(postData),
success: function (data) {
console.log(data);
console.log('MS Flow triggered successfully');
},
error: function (error) {
// error handler code goes here
console.log(error)
}
});
}
beginMSFlow();
Comments
Post a Comment