Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Save and Reload form or full Refresh

Posted on by 390

Hi,

I am having problem in CRM form save and refresh.

Once I save the form using javascript command Xrm.Page.data.entity.save(), the page is not refreshed. I need to full refresh the form. Because after saving all fields will be disabled, but that is not happening unless I manually reload the form again after save.

I used the Xrm.Utility.openEntityForm() command to reload after save command, but this time I am getting a popup "Your changes are not saved. are you navigate from this page". This is because the Xrm.Utility.openEntityForm() is executed even before the save operation is completed. looks the save is asynchronous.

Questions:

1. Why CRM does not reload the form automatically on save

2. How to do synchronous save using javascript command

3. Why Xrm.Page.data.entity.save().then(success, failure) is not working.

4. What is the solution to save the form, and then reload the form again.

*This post is locked for comments

  • Naushad Kakarla Profile Picture
    Naushad Kakarla 120 on at
    RE: Save and Reload form or full Refresh

    Did you ever find a solution to your issue?

    I am in the same boat.

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

    How about this:

    function Form_onsave() {
         . . .


        // REFRESH to display the newly exposed fields' data.
        // community.dynamics.com/.../173659
        if (Xrm.Page.data.entity.getIsDirty()) {
            Xrm.Page.data.save().then(function () {    // The save prevents "unsaved"-warning.
                Xrm.Page.data.refresh();
            }, null);
        }

        // Refresh the Annotation List
        . . .
    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload form or full Refresh

    Hi Jayakumar,

    it seems form Refresh issue has resolve by using Refresh() method

    Now your are facing the problems to disabled the controls you should use the following script to disabled the control Xrm.Page.getControl("fieldname").setDisabled(true);

    Try to call following script onload of form this:

    if(Xrm.Page.ui.getFormType()==2) //check for update

    Xrm.Page.getControl("fieldname").setDisabled(true);

    Thanks

  • Jayakumar Profile Picture
    Jayakumar 390 on at
    RE: Save and Reload form or full Refresh

    Hi Arif,

    The form is editable initially. After some field value is set to particular value and save, then all fields will be set to read-only. But after save the field is still editable. I have to reload the form to make the fields disabled.

  • Jayakumar Profile Picture
    Jayakumar 390 on at
    RE: Save and Reload form or full Refresh

    Hi Muhammad,

    I tried the refresh command also. The fields will be read-only after I save. But after refresh command the fields are still editable. After reloading the page the fields are marked read-only.

  • Jayakumar Profile Picture
    Jayakumar 390 on at
    RE: Save and Reload form or full Refresh

    Hi Erik,

    Dirty fields are modified fields. So it should be saved along with the save command right?

  • arif imteyaz Profile Picture
    arif imteyaz 375 on at
    RE: Save and Reload form or full Refresh

    you can call js on change event.

  • Nuno Profile Picture
    Nuno 2,005 on at
    RE: Save and Reload form or full Refresh

    Hi,

    Don´t you have any other javascript function working onSave event which changes some fields values?

  • arif imteyaz Profile Picture
    arif imteyaz 375 on at
    RE: Save and Reload form or full Refresh

    when form readonly then data will not save from Xrm.Page.data.entity.save()

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Save and Reload form or full Refresh

    Hi,

    After calling save method on form as you are calling Xrm.Page.data.entity.save();

    You need to call the Refresh Method as well it refresh the saved form and changes are done.

    Xrm.Page.data.entity.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

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans