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 Apps / Calling Flow from Java...
Power Apps
Unanswered

Calling Flow from JavaScript - works from a browser not from Dataverse form

(0) ShareShare
ReportReport
Posted on by 1

Hello

I need to check values from a Dataverse form, based on existing Sharepoint subsites.
The user starts a precheck from the Dataverse form, a javascript should fire a Power Automate flow, and tell the user the precheck is done (or failed).
I followed these contents to write JS : softchief  & How to build a Real-Time Power Automate Cloud Flow

 

The starting point component in the flow is 'when an http request is received', anthentication set to none, the generated url is pasted in the JS.
When passing this url in a browser, we have a result and we see in the flow execution history that the flow was fired.
When the JS is launched, messages are promted but the progress indicator never ends and there is nothing new in the flow execution history.


In the Power Platform Admin Center, the admin mode of the organisation is disabled.

Any idea ?

 

 

// mon commentaire
function runPowerAutoPreCheck(executionContext) {
	alert("on manoeuvre +-+-+0001");
	var formContext = executionContext.getFormContext();
	var sousSiteGuid = formContext.data.entity.getId();
	var ssType = formContext.getAttribute("jxsp_type").getValue();
//[...]
	var ssEntreprise = formContext.getAttribute("jxsp_entreprise").getValue();
	var ssBilan = formContext.getAttribute("jxsp_bilanexecution").getValue();
	// stop if key fields do nt have data
if (ssEntreprise==null||1==2) {
	Xrm.Utility.closeProgressIndicator();
	return;
}
var PAParameters = {
	"sousSiteGuid": sousSiteGuid,
	"ssType": ssType,
//[..]
	"ssEntreprise": ssEntreprise,
	"ssBilan": ssBilan
}


alert("on manoeuvre 0002 /\ Entreprise =" +ssEntreprise+" json = "+JSON.stringify(PAParameters));

// url points to specific power automate
var url = "https://prod-34.westeurope.logic.azure.com:443/workflows/c8d...............a7/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=wQHtE...........ux-1WBE.........mEA";
var req = new XMLHttpRequest();
req.open("POST",url,true);
req.setRequestHeader('Content-Type','application/json');
//Xrm.Utility.alertDialog("Power Automate running");
req.send(JSON.stringify(PAParameters));
alert(" the rest is never shown ... ");
req.onreadystatechange = function () {
	if (this.readyState ===4) {
		req.onreadystatechange = null;
		if (this.status ===200) {
			var result = this.response;
			// alert("" + result);
			//formContext.data.refresh(false);
			formContext.data.refresh(true);
			Xrm.Utility.closeProgessIndicator();
		}
		else if (this.status === 400){
			Xrm.Utility.closeProgessIndicator();
			alert(this.statusText);
			var result = this.response;
			alert("Error : " + result);
		}
	}
};

Xrm.Utility.showProgressIndicator(' SharePoint Precheck en cours ');

//req.send(JSON.stringify(PAParameters));
//req.send();
}

 

 

I have the same question (0)
  • Shashank Bhide Profile Picture
    942 Moderator on at

    Click on "F12" on your browser, open Dev tools and find out what's going wrong when you click the button, something on the network call is going wrong.

     

    Having said that, there are other security issues, you've copied the URL in plain text which could be misused by an attacker.

     

    Instead of "XmlHttpRequest" try to use "fetch".

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard