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 thought on “Dynamics 365 – Hide/Disable/Edit Business Process Flow Fields using JavaScript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s