RE: Web resource button to trigger a Power Automate Flow
Hi Sam,
In the form_load function, you are passing two parameters to setClientApiContext function of the web resource button page.
contentWindow.setClientApiContext(Xrm, formContext);
It may causes confusion to setClientApiContext function of the web resource, because there is only one parameter:
function setClientApiContext(formContext) {
window._formContext = formContext;
}
Please remove Xrm and only keep formContext to test again.
Alternatively, if the error is still not resolved by above step, you could try following approach:
1. Change the form_onload to:
function form_onload(executionContext) {
var formContext = executionContext.getFormContext();
window.top._formContext = formContext;
}
Instead of passing parameters to web resource, we set formContext as a window level property.
2. In the button page, remove setClientApiContext function. In PostFlow function, extract the formContext from window object directly.
function PostFlow() {
var formContext = window.top._formContext;
var quote = formContext.data.entity.getId().replace(/\{|\}/gi, "").toLowerCase();
// Same
}
Regards,
Clofly