REGISTER AND CALL EVENT HANDLERS FOR BUSINESS PROCESS FLOWS (BPF)
In this post, I will mention some of the events that are used against Business Process Flows.
Even though these events are executed from the form context, but,
they are not registered directly from the form editor like On Load, On Save, On Change events.
Instead, these events can be registered and called from the JavaScript while loading the form in the OnLoad event of the form.
Below are some of the BPF events that can be registered:
- OnPreProcessStatusChange: This function will be executed before the BPF status changes and can be called as follow formContext.data.process.addOnPreProcessStatusChange(functionName)
- OnPreStageChange: This function will be executed before the BPF stage changes and can be called as follow formContext.data.process.addOnPreStageChange(functionName)
- OnProcessStatusChange: This function will be executed when the BPF status changes and can be called as follow formContext.data.process.addOnProcessStatusChange(functionName)
- OnStageChange: This function will be executed when the BPF stage changes and can be called as follow formContext.data.process.addOnStageChange(functionName)
- OnStageSelected: This function will be executed when the BPF stage is selected and can be called as follow formContext.data.process.addOnStageSelected(functionName)
In the JavaScript file, register the needed BPF events on the onLoad function that is registered on the OnLoad event of the form:
function onLoad(context) {
AddBPFStageEvents(context);
}
function AddBPFStageEvents(context) {
var formContext = context.getFormContext();
formContext.data.process.addOnStageChange(stagechange);
formContext.data.process.addOnStageSelected(stageselected);
}
function stagechange(context) {
var alertMessage = { text: "Stage changed event triggered." };
Xrm.Navigation.openAlertDialog(alertMessage, null);
}
function stageselected(context) {
var alertMessage = { text: "Stage selected event triggered." };
Xrm.Navigation.openAlertDialog(alertMessage, null);
}
In this post, I wrote about another function that can be used with the BPF.
For a full list and more details of the event handlers that can be used with the BPF, you can take a look at this docs link
Hope This Helps!
Comments
Post a Comment