Dynamics 365 – Hide/Disable/Edit Business Process Flow Fields using JavaScript

In Dynamics 365, Business Process Flow attributes are just like Form attributes. You can use most of the controls in the same way as you normally do for Form attributes. Let’s look at the most common ones together.

Get Business Process Flow attribute control using Javascript

To get attributes Add “header_process” before schema name of field. Let’s say your attribute schema name is “cm_myattribute“.

function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');
    var bpfAttribute = bpfControl.getAttribute();
}

Set attribute value for Business Process Flow using Javascript

function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');
    var bpfAttribute = bpfControl.getAttribute();

    if (bpfAttribute != undefined) {
        bpfAttribute.setValue("myValue");
    }
}

Hide field in a Business Process Flow using Javascript

function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');

    bpfControl("header_process_cm_myattribute").setVisible(false);
}

Set field Required in a Business Process Flow using Javascript

function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');
    var bpfAttribute = bpfControl.getAttribute();

    if (bpfAttribute != undefined) {
        attribute.bpfAttribute("required");
    }
}

Set field Disable in a Business Process Flow using Javascript

function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');
    bpfControl.setDisabled(true);
}

One response to “Dynamics 365 – Hide/Disable/Edit Business Process Flow Fields using JavaScript”

  1. […] control using Javascript To get attributes Add “header_process” before schema name of … Continue reading Dynamics 365 – Coding Business Process Flow Attributes using JavaScript Read Complete Post and Comments $(document).ready(function(){ if(”!=”) { $(“.post […]

Leave a reply to Dynamics 365 – Coding Business Process Flow Attributes using JavaScript – Microsoft Dynamics 365 Community Cancel reply