Skip to main content

Notifications

Dynamics 365 Community / Forums / Sales forum / BPF is disappearing on...
Sales forum
Suggested answer

BPF is disappearing onLoad of form

Posted on by 10

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.

pastedimage1676549703364v1.png

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!

Categories:
  • Suggested answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: BPF is disappearing onLoad of form

    Hi AJSingh,

    Ensure that there are not more JS Files OnLoad.

    Probably there are script hidding it, Your could place a JS function at the end of the OnLoad form doing this

    function showBPFifHidden(context)
    {
    let formContontext = context.getFormContext();
    let bpf = formContontext.ui.process;
    if(!bpf.getVisible())
        bpf.setVisible(true);
    
    }

    this is just a patch, but you should look in your scripts the reason why its being hidden.

    If it was helpful please consider mark it as answer

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,115 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,971 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans