How to lock fields on a Form and Business Process Flow

Lock Business Process Flow fields only

The function below locks all fields which contains the word “header_process_” this ensures that only fields that are in the Business Process Flow are locked and not on the form.

CRM.lockAllBPFFields = function (formContext) {
    formContext.ui.controls.forEach(function (control, index) {
        var controlName = control.getName();
        if (controlName.indexOf("header_process_") !== -1) {
            control.setDisabled(true);
        }
    });
};

Lock form fields only

The function below locks all fields which does not contain the word “header_process_” this ensures that only fields that are on the form are locked and not on the Business Process Flow.

CRM.lockAllFormFields = function (formContext) {
    formContext.ui.controls.forEach(function (control, index) {
        var controlName = control.getName();
        if (controlName.indexOf("header_process_") === -1) {
            control.setDisabled(true);
        }
    });
};

Lock Business Process Flow and form fields

The function below locks all fields on the form and on the Business Process Flow. This solution is pretty good if you need to lock the entire form. It captures all the header fields and also any duplicate fields on the form.

CRM.lockAllFields = function (formContext) {
    formContext.ui.controls.forEach(function (control, index) {
        control.setDisabled(true);
    });
};

Leave a Reply

Your email address will not be published. Required fields are marked *