Hi All,
I'm trying to disable stage transition on a BPF for all users.
Following the suggestion at https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/onprestagechange I'm registering the below function on form load:
onLoad = (executionContext) => {
//Attach pre-stage change handler
formContext.data.process.addOnPreStageChange(() => { this.stageChangeWarning(executionContext) });
};
The stageChangeWarning function looks like this:
stageChangeWarning = (executionContext) => {
//Compose notification obj
const notification = {
type: 2,
level: 2,
message: "This is automated process. Moving between stages from there is not allowed.",
showCloseButton: true
}
//Prevent stage change.
executionContext.getEventArgs().preventDefault();
//Trigger notification.
Xrm.App.addGlobalNotification(notification).then(function onSuccess(result) {
//Remove noticication message after 10 seconds
window.setTimeout(function () {
Xrm.App.clearGlobalNotification(result);
}, 10000);
})
};
However when I test it I receive "executionContext.getEventArgs(...).preventDefault is not a function" error & the form is saved as expected.
Do you happen to know what I'm doing wrong here?