Wednesday 14 June 2023

Read Values from SubGrid through JavaScript

   var gridContext = formContext.getControl("Subgrid_new_Applications");



      

            var appRows = gridContext.getGrid().getRows();


            //var RowCount = appRows.getLength();


        appRows.forEach(function (row, i) {

            var gridColumns = row.data.entity.attributes;

            console.log("Application Id =" + row.data.entity.getId());

            gridColumns.forEach(function (column, j) {

                var atrName = column.getName();

                var atrValue = column.getValue();

                console.log(atrName + ":" + atrValue);

            });


        });

Tuesday 6 June 2023

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“.

1
2
3
4
5
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

1
2
3
4
5
6
7
8
9
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

1
2
3
4
5
6
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

1
2
3
4
5
6
7
8
9
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

1
2
3
4
5
function BpfControls(executionContext) {
    var formContext = executionContext.getFormContext();
    var bpfControl = formContext.getControl('header_process_cm_myattribute');
    bpfControl.setDisabled(true);
}

Hide New... button on lookup controls in model-driven apps

  The 'New ...' button is shown upon opening the lookup search dialog whenever the logged in user has at least user create privileg...