Below is the ajax call that i am using
document.getElementById("UpdateButton")?.addEventListener("click", function (event) {
console.log("Is this working");
var SAP_OPOR = crc81_sap_opor_name.value;
var LineNum = crc81_linenum.value;
var _url = "/_api/cloudflow; -- removed the full url
var data = {};
data["SAP_OPOR"] = SAP_OPOR;
data["LineNum"] = LineNum;
//debugger;
var payload = {};
payload.eventData = JSON.stringify(data);
shell.ajaxSafePost({
type: "POST",
url: _url,
// contentType: "application/json",
data: payload,
// "origin": "*",
//cogs : true,
})
.then(response => {
// Assuming the flow returns data that you want to display
// Display the return value in an element, e.g., with class 'description'
const result1 = JSON.parse(response);
debugger;
console.log(result1);
alert("worked 1");
localStorage.setItem("SupplierPowerAutomateOutput1",result1["varoutput"]);
})
.done(function (response) {
const result = JSON.parse(response);
debugger;
console.log(result);
alert("worked 2");
localStorage.setItem("SupplierPowerAutomateOutput2",result["varoutput"]);
onSuccess();
})
.fail(function () {
alert("failed");
});
});
});
In failure, it does return to the .fail when i force an error on the workflow that is not caught
In the existing case. The workflow return success, so i was expecting the ajax to either get into .then or .done which would return the response from power automate
The workflow pushes data to SAP. And my outcome is to return that message as a text onto power pages. (for the moment its a fixed value to get it functioning first)
But as i do not get the response in the result1["varoutput"], i am not able to return it onto the front end