Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Save and Reload

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi

When we save the form in CRM2011, it reload automatically but in CRM2015 it just save the content of form and does not load and open the page again. How could I add java script code to solve this problem ? I used refresh code  to achieve this target, but it seems does not save the content and appears an unsaved changes error when refreshes it.

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

Xrm.Page.data.refresh();

when I use these codes , it wants to Leave or Stay in the page:

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

 window.location.reload(true);

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    I  had a similar problem: my form changes state on-save depending on user selections but newly exposed fields (inc. those in Quick Views) did not show the associated data, they were "unset". The technique suggested by Muhammad Siddique is straightforward, I simply added his code to the end of my "Form_onsave()" function, and it works flawlessly for me. Thank you Muhammad ;)

    Muhammad's fix code, again:

     if (Xrm.Page.data.entity.getIsDirty()) {
           Xrm.Page.data.save().then(function () {
                       Xrm.Page.data.refresh(); 
           }, null);
     }

    I suggest that Muhammad's reply is marked as a Verified Answer.

    UPDATE: Since posting the above, my needs have changed (I now want to refresh the page every time a user clicks "Save") and so I  was able to replace the above block of code with this single line:

    Xrm.Page.data.refresh(true);  // Refresh saving entity if updated.


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    Thanks For the solution..

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    Hi everybody

    I finally find solution:

    I write "Xrm.Utility.openEntityForm(“<entity name>”, Xrm.Page.data.entity.getId());" code on change of "modify on " field of the form

  • Siddique mahsud Profile Picture
    Siddique mahsud 11 on at
    RE: Save and Reload

    You can use following code: 

     if (Xrm.Page.data.entity.getIsDirty()) {
           Xrm.Page.data.save().then(function () {
                       Xrm.Page.data.refresh(); 
           }, null);
     }

  • RE: Save and Reload

    Please mark my answer as verified if you found it helpful

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    Thank you Rajkumar

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    and obviously I use my Entity name

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload

    I use this respectively :

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

    Xrm.Page.data.refresh();

    Xrm.Utility.openEntityForm(“<entity name>”, Xrm.Page.data.entity.getId());

  • RE: Save and Reload

    Share your code on here

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans