Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Subgrid modification forcing main form refresh

(0) ShareShare
ReportReport
Posted on by 210

We have a custom entity.  The main form for this entity contains several subgrids and also an HTML web resource.  Per normal Dynamics when a user clicks on the add sign the related entity in question opens and the user is allowed to add a new record.  Upon close they return to the main form where the subgrid has been updated (happens upon save).  All as expected.  The HTML web resource at times needs to be refreshed due to the data entered/modified on one of these related entities in the subgrids.

Is there a way to capture that a subgrid has been updated so that we can trigger a form refresh?

Thanks....Diane

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Subgrid modification forcing main form refresh

    Hi Diane,

    Depends on  your requirement please proceed to implement. 

    Refresh Form Subgrid form Add new Popup window , Replace the subgrid Name. You may need to add additional "parent" if you are showing the subgrid inside TAB. You need to register  the function (onSavePopUp) in the OnSave method of Add New window of subgrid.

            //Refresh Form Subgrid From Add New Popup window
            function onSavePopUp() {
                Xrm.Page.data.save().then(executeSubmitSuccessfulCallback, executeSubmitErrorCallback);
            }
    
            function executeSubmitSuccessfulCallback() {
                var subgrid = document.parentWindow.parent.parent.opener.Xrm.Page.ui.controls.get("SUBGRID ID"); // Replae the subgrid Name. You may need to add addtional parent if you are showing the subgrid in a TAB.
                subgrid.refresh();
                Xrm.Page.data.entity.save('saveandclose');
            }
    
            function executeSubmitErrorCallback() {
    
            }


    Refresh the data in the Form , Using  Xrm.Page.data.refresh method you can manually force the page to display the current values.

      Xrm.Page.data.refresh();


    If you have any web resource in the form you can simply set the webresource URL to refresh particular form.

      

     var url = Xrm.Page.getControl("WebResource_Name").getSrc
     Xrm.Page.getControl("WebResource_Name").setSrc(null);
     Xrm.Page.getControl("WebResource_Name").setSrc(url);

    Please note when you will calling Xrm.Page method from popup its trigger only the pop window context , not  for parent form . So you need to debug and check to get the control from parent form like below.

    document.parentWindow.parent.parent.opener.Xrm.Page // You may need to add additional parent here .


    Hope this helps.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Subgrid modification forcing main form refresh

    Hi

    Please have a  look on below reference

    community.dynamics.com/.../254858

    Thanks

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans