We have a custom entity called PMDW and its has 2 BPF(Business Process Flow). BPF switches based on the logged in user. It was working properly till yesterday, now its starts breaking. The BPF is disappearing onLoad of the form or moving the stage for the first time.
The user has all the required access.
JS onLoad of Form:
var onSaveConfirmDialog = false;
function OnLoad(executionContext) {
"use strict";
var formContext = executionContext.getFormContext();
formContext.getControl("header_process_createdby").setVisible(false);
formContext.getControl("header_process_createdby_1").setVisible(false);
formContext.getControl("header_process_createdby_2").setVisible(false);
formContext.getControl("header_process_createdby_3").setVisible(false);
if (formContext.getControl("header_process_aeso_transmissionrelated") !== null) {
formContext.getControl("header_process_createdby_4").setVisible(false);
formContext.getControl("header_process_createdby_5").setVisible(false);
}
SetActiveBPF(executionContext);
}
function SetActiveBPF(executionContext) {
"use strict";
var stageName = null;
var formContext = executionContext.getFormContext();
var formType = formContext.ui.getFormType();
var roles = Xrm.Utility.getGlobalContext().userSettings.roles.getAll();
var activeStage = formContext.data.process.getActiveStage();
if (activeStage !== null && activeStage !== undefined)
stageName = activeStage.getName();
else
formContext.data.refresh();
var roleNames = [];
for (var i = 0; i < roles.length; i++) {
var roleName = roles[i].name;
roleNames.push(roleName);
}
if (stageName === "Initiate" || formType === 1 || roleNames.indexOf("Tariff Ops External User") > -1) {
formContext.data.process.setActiveProcess("52D250A9-2C5D-ED11-9562-000D3A09D5DE", "success");
}
else {
formContext.data.process.setActiveProcess("BF94B9BF-2C5D-ED11-9562-000D3A09F26D", "success");
}
}
function callBackFunction(result) {
if (result == "success") { }
else { }
}
function OnFormSave(executionContext) {
"use strict";
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() === 1 && !onSaveConfirmDialog) {
executionContext.getEventArgs().preventDefault();
var confirmStrings = {
text: "Are you sure you want to continue to save the record?", title: "Warning",
cancelButtonLabel: "Cancel", confirmButtonLabel: "Continue"
};
var confirmOptions = { height: 100, width: 350 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {
if (success.confirmed) {
onSaveConfirmDialog = true;
//Xrm.Page.data.entity.save();
formContext.data.save().then(function () {
Xrm.Page.data.refresh();
});
}
else {
onSaveConfirmDialog = false;
}
});
}
}
Can you guys suggest any resolution?
Thanks in advance!