Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to save and refresh editable SubGrid with JavaScript

Posted on by Microsoft Employee

I am having trouble with users forgetting to save within an editable subgrid. I would like to be able to save and refresh an editable subgrid with javascript so that I can add it to the on save event for the form.

Is this possible, I did not see it in any of the current documentation?  

Thanks in advance!

*This post is locked for comments

  • Suggested answer
    Kathan Profile Picture
    Kathan 20 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    you can also try by using a JS web resource by adding a event handler  on  main form save  ,  calling a function

    function refresh(executionContext) {

       var formContext = executionContext.getFormContext();

         formContext.ui.refresh();

    }

  • ASukiasyan Profile Picture
    ASukiasyan 10 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi, did you find any solution to this? I am facing a similar issue.

  • Divya Bharti Profile Picture
    Divya Bharti 55 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi i have added code on onchange event of subgrid to setvalue of column but the problem is on setvalue it just displays value in column but on page refresh it discard changes. The main problem is crm subgrids are not exposing its save method to users and i need to bypass it

    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();

    attrParent.attributes.get("aga_anwendungshinweis").setValue(InstructionFieldParent[0].name);

    }

  • Suggested answer
    Clem Profile Picture
    Clem 2,541 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi,

    Why not using the OnChange event within the editable grid ? as Mahadeo suggested : msdn.microsoft.com/.../mt788311.aspx

    Everytime the value change, you save it (it's a bit big for process but ...).

    If you want to make sure that the changes are always saved i assume that's the way to go.

    Clément

  • Divya Bharti Profile Picture
    Divya Bharti 55 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi did you find any solution on this?

    I am facing similar issue and no workaround i found till now.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Thank you for the response but unfortunately this does not help either. For example the user edits a value in the subgrid and then clicks back to the main form it will not save the subgrid edit. Then if the user either manual or auto saves the main form it will lose the information that they changed in the subgrid.

    Really I just need a way to save the subgrid with JS so that I can add it to the onSave event of the main form.

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi,

    Autosave is supported for editable grids.

    neilparkhurst.com/.../dynamics-365-editable-grids/

    In order to refresh the subgrid, you could use the code below.

    var subgrid = Xrm.Page.ui.controls.get("subgridname");
    subgrid.refresh();

    See: community.dynamics.com/.../148240

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to save and refresh editable SubGrid with JavaScript

    I have looked at these and have some JavaScript functions working with editable grids but unfortunately I cannot find a way to save the items in the editable subgrid with JavaScript.

  • Mahadeo Matre Profile Picture
    Mahadeo Matre 17,021 on at
    RE: How to save and refresh editable SubGrid with JavaScript

    Hi,

    check this

    msdn.microsoft.com/.../mt788311.aspx

    www.inogic.com/.../events-in-dynamics-365-editable-grid

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans