Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

Posted on by Microsoft Employee

Hi everyone!

I am updating a field of the Parent Entity from the Child Entity's quick create form. So when the child record is saved , i use the CRM SDK to update a field in the Parent form.

I noticed that the updated value is displayed only with a refresh. I would like when i save the child record , to update the value and show it instantly , so i decided to refresh the parent entity form. I tried the 

Xrm.Utility.openEntityForm(parentEntityName,parentEntityId) but it opens new window. I want to close the Quick create form and then refresh the parent form where i return to.
Any ideas?
Thanks!

*This post is locked for comments

  • SP211 Profile Picture
    SP211 130 on at
    RE: Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

    Hi Shak, is this something that can also be done via the Portal?  We have a similar scenario where we want to reload the portal page after a subgrid item has been edited.

    Thanks

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

    Hi Shak,

    As vahid suggested.

    If you have subgrid of child entity in parent form, When ever you update child record the grid will be refreshed, On Sub grid refresh event you can reload your parent page.

    Hemant

  • Suggested answer
    Vahid Samimi Profile Picture
    Vahid Samimi 210 on at
    RE: Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

    hi

    other solution is use subgrid event like this:

    var refreshForm= function () {Xrm.Page.data.refresh()  };
    Xrm.Page.getControl("Your SubgridName").addOnLoad(refreshForm);


  • Suggested answer
    Luke Sartain Profile Picture
    Luke Sartain 1,266 on at
    RE: Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

    I did something similar for this:

    var thisQuote = {

               entityType: "quote",

               id: Xrm.Page.data.entity.getId()

           };

    Xrm.Utility.openQuickCreate(entityname, thisQuote, null).then(function (outObj) { successCallBack(outObj) }, function (error) { console.log(error.message) });

    function successCallBack(outputObj){

    setTimeout(function () { Xrm.Page.data.refresh(); }, 500);      

    }

    The timeout is used to give the quick create form time to close when using turbo forms before it refreshes.  

    msdn.microsoft.com/.../jj602956.aspx

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Refresh Parent Entity form when updating a field (in Parent form) from Child Entity using Javascript

    Hi,

     I don't think there is an Xrm method for this - you might, probably, figure out how to get back to the "parent" form through the window.parent.

     Or, since it's javascript, you might add a function to the window.top(might just add this as a web resource - you probably don't even need an event handler on the "parent" form):

     function OnQuickCreateClose()

     {

     }

     window.top.OnQuickCreateClose = OnQuickCreateClose;

     And might call that function from the onsave in your Quick Create.. although, you might want to add a timeout before calling refresh in that function (since you would want quick create to save the data first)

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans