Monday, June 15, 2020

Dynamics 365 - Editable Grid Concepts

Dynamics 365 - Editable Grid overview with example


Editable Grid is one of the greatest releases from dynamics 365. In this post, I will share its capability and how to configure the editable grid from the entity level as well as SubGrid present on the entity form.

I will describe the basics of editable grids, including how to use them and how to configure them and also how to customize their behavior with JavaScript. 

Using Editable Grids

The following features are supported with editable grids;

  • Inline editing
  • Sorting
  • Grouping
  • Filtering
  • Pagination
  • Calculated and Rollup Fields
  • Run time resize/move columns
  • AutoSave / Manual Save
  • Toggle between read-only and editable grid
  • Filtered lookups
  • Chart panel interaction
  • Command bar interaction
  • Business Rules (Including, show error messages, set field value, the set business required, set the default value, lock or unlock)
  • JavaScript 

Enable Editable Grids

I’ve already mentioned editable grids are custom control, you, therefore, enable them in a similar way as you would for other custom controls.

In customizations navigate to the required entity. Then select the “Controls” tab and the “Add Control…” link.

Next, select “Editable Grid” and click Add.

Now you’ll need to select which clients you wish to enable editable grids on. Below you can see that I have selected the web client and the tablet client.

Tip:
There are some additional properties on editable grids that you may wish to edit. (I will describe these later in this post.) But just adding the grid-like this is enough to get it working!

Enable on sub-grids

It’s also possible to enable editable sub-grids on forms. The process is similar to enabling them on “home” grids. Simply navigate to the sub-grid control on the form in customizations, then use the controls option.

You can use the “Add Control….” link as already shown, or if the entity is already enabled for sub-grids you and created an editable grid using the settings for the home views as a template.

Once added the options for sub-grids are identical to those on the home grids.

Group By

A new addition in editable grids is the ability to group results. This feature is enabled by default but can be turned off when required. (Although generally speaking I imagine you’ll leave this feature enabled!)

Below you can see that I can group opportunities by any column on the grid.

To disable grouping simply “tweak” the properties on the editable grid control. Selecting the “edit” icon shown below will allow you to enable/disable grouping.

Notice that this is simply an option to enable or disable the grouping. I don’t have any capability to select which columns are available in the group by dropdown.

Lookup Views

Lookups on grids can be filtered to only show related record. It is also possible to enable users to override this filtering if required. The example below will show only related contacts in the primary contact field on the account.


Selecting the “edit” icon lets us control the properties …

Note:
Filtering lookups are by the view! When you first select the “Add Lookup” option you’ll need to select the view this lookup will be applied to. Meaning you can have different logic on different views. The example screenshots below related to the “Active Accounts” view, whilst the lookup example below will be applied to the “My Active Accounts” view. This is great in terms of flexibility but if you have the same column repeated on many views you will need to add the lookup option is all of your views.

Nested Grids

Firstly, I should remind you that nested grids only apply to the mobile client. (At least in the current release of Dynamics 365!)

Tip:
It is actually possible to define a nested grid but only have the editable grid available to the web client. This doesn’t create an error but also doesn’t achieve anything!

When defining a nested grid, we have two options to edit! (See below)

The first option we define is to set which entity to open and which view to use. Meaning we can only have one type of nested grid!

Consider accounts, it might be useful to have a nested view of opportunities. In other circumstances, a nested view of cases might be more helpful. You can do either but you can’t do both at the same time!

Having defined the entity and view to see in our nested grid we use the “Nested grid parent ID” option to define the binding between our primary entity and the nested entity. In the example of opportunities for accounts, we’d bind to the “parentaccountid” field on the opportunity.

Limitations / Considerations

Some things to consider with editable grids include;

  • Read-only fields on the form aren’t read-only! Making a field read-only on a form, only applies to that form. Often a better approach is to use field-level security. (Or use JavaScript!)
  • Editable Grid version of a sub-grid takes up more space than the read-only grid (especially if you enable the Group By feature).  Allow for a larger sub-grid to make sure your users see the same amount of data they used to.
  • Enabling editable grids on a home grid is a global setting!
  • Enabling editing on a subgrid is a per sub-grid basis meaning that every sub-grid on every form and dashboard must have their editable setting enabled individually.
  • Some fields are not editable in the editable grid:
    • Fields from related entities
    • State, StateCode
    • Customer fields (e.g., on an Opportunity or Case)
    • Composite fields
    • Party List fields (e.g., the To field on an Email)
    • Field Level Secure fields (if your field security profile prevents you from editing the field)
  • Nested grids only apply to the mobile client.
  • Editable Grids support JavaScript for the home grid and sub-grids, for OnRecordSelect, OnSave, OnChange events.
  • Editable Grids support entity-level business rules for ….
    • Show error message
    • Set field value
    • Set business required
    • Set default value
    • Lock or unlock the field
  • JavaScript, Xrm.Page (FormContext ) is used to referencing objects on the CRM forms this approach doesn’t work with editable grids.


Reference: https://neilparkhurst.com/2016/12/30/dynamics-365-editable-grids/