Auto-Save Editable sub-grid

If you are working with editable grid, then there is a very common problem user faces that they always forget to save that grid and proceed further with the next business step on MSD 365 form.

The strange part is when the user makes some changes on the grid and saves the data, data won’t be saved but if they click on ‘Save and Close’ data gets saved. But with this user needs to open the same record again to proceed next.

To resolve this, we can write small JavaScript, which will take care of auto-save for the editable grid. Well, here are the step for that,

  1.  Open Sub-grid properties
  2. Go to events
  3. choose the attributes, where we want to be autosaved must be triggered
  4. Put the function name and pass the execution context to the function (Call JS)

Save sub-grid

.. and here is the code snippet for it.

//save sub grid ...
function SaveSubGrid(eContext) {

    var nameAttr = eContext.getEventSource();

    var attrParent = nameAttr.getParent();

    var InstructionFieldChield = nameAttr.getValue();

    var InstructionFieldParent = InstructionFieldChield;

    nameAttr.setValue(InstructionFieldParent)

    Xrm.Page.data.entity.save();
    
}

That’s it!

Thanks.

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 )

Google photo

You are commenting using your Google 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