This time, I want to refer to an article which helped me today:

“magnetism – Adam Murchison”

Editable grids are an awesome new feature within Dynamics 365, if you haven’t had a chance to play around with them then I suggest you do.

Inside the editable grid the JavaScript on the main form is not mimicked within. To apply your own JavaScript on an editable grid is very easy, in this blog I’m going to show one example of locking specific fields within the editable grid (In this case; the registration status). The reason I’m using this example is because there is no out of the box functionality to make a field read only in an editable grid.


First, let’s create the JavaScript we are going to apply to lock an array of fields in CRM. It is a very simple method:
This method loops through each field on the editable grid and if it’s in the ‘disabledFields’ array then disable the field.

function gridRowSelected(context) {

 LockFieldsOnEditableGrid(context, ["mag_registrationstatuscode"]);


LockFieldsOnEditableGrid = function (context, disabledFields) {

var currEntity = context.getFormContext().data.entity;

 currEntity.attributes.forEach(function (attribute, i) {

if (disabledFields.indexOf(attribute.getName()) > -1) {

var attributeToDisable = attribute.controls.get(0);






Then add this JavaScript as a web resource or to an existing web resource.

Secondly go to the form you’d like to apply JavaScript to, for this example I’d like to be able to edit Registrations on an Event record i.e. on the Registration sub-grid.


Once the Editable Grid has been added to the SubGrid, the Events tab will appear and this is where you can add in the web resource you created earlier and ensure the Event trigger is OnRecordSelect. There are other events to trigger the JavaScript on such as ‘OnChange’ which is triggered when a specific field is changed within the editable grid and ‘OnSave’ which triggers the JavaScript when the record is saved.



Next add in the function and ensure that you are passing in the execution context as the first parameter.


Easy as that, as shown in the screenshot above you can now see that the Registration Status is locked. Now you have the power to enable JavaScript on an editable grid.





Leave a Reply

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

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Miss Ob·so·let

Imperfection is beauty, madness is genious. it is better to be absolutely ridiculous than absolutely boring.


nice to know


, , , , , , , , ,