web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to save and refresh editable SubGrid with JavaScript

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Mahadeo Matre Profile Picture
    17,021 on at
  • Community Member Profile Picture
    on at

    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.

  • Nithya Gopinath Profile Picture
    17,078 on at

    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
    on at

    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.

  • Divya Bharti Profile Picture
    55 on at

    Hi did you find any solution on this?

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

  • Suggested answer
    Clem Profile Picture
    2,541 on at

    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
    55 on at

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

    }

  • ASukiasyan Profile Picture
    10 on at

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

  • Suggested answer
    Kathan Profile Picture
    20 on at

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

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans