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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Save and Reload form or full Refresh

(1) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Save and Reload form or full Refresh

    Sounds like you may have scripts or something causing so-called "dirty fields" on save.

    Try this in the browser console and see what fields you may get:

    frames[0].Xrm.Page.data.entity.getDataXml();

  • Community Member Profile Picture
    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();

  • arif imteyaz Profile Picture
    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()

  • Nuno Profile Picture
    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
    375 on at
    RE: Save and Reload form or full Refresh

    you can call js on change event.

  • Jayakumar Profile Picture
    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?

  • Jayakumar Profile Picture
    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
    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.

  • Community Member Profile Picture
    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

  • Suggested answer
    Community Member Profile Picture
    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
        . . .
    }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans