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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

javascript - dynamics 365 - refresh form

(0) ShareShare
ReportReport
Posted on by 694

Helo,

I have Microsoft CRM 365 on Line, but I need javasript to refresh the page when I click the button, what would be the Javascript I use to refresh the page considering the context?

Tanks

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I believe this is what you need - docs.microsoft.com/.../refresh

  • Suggested answer
    LeoAlt Profile Picture
    16,341 Moderator on at

    Hi partner,

    Since you want to click a ribbon and then refresh the form, there are 2 steps you need to do.

    1.Use Ribbon Workbench to add a custom ribbon on your form.

    http://www.develop1.net/public/rwb/ribbonworkbench.aspx

    https://www.itaintboring.com/dynamics-crm/application-ribbon-in-dynamics-or-how-can-we-add-a-button-to-all-entity-forms/

    2.Add the js code as a web resource to Dynamics 365 and trigger the js function in your custom ribbon in ribbon workbench.

    //refresh the form
    function refreshForm(){
        Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    }

    Hope it helps.

    Best Regards,

    Leo

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Thanks for the reply,

    I ran the formContext.data.refresh (save) .then code (successCallback, errorCallback) I'm getting the "save is not defined" error, below is the code I'm running


    function test (executionContext)
    {
    debugger;
    try
    {
    var formContext = executionContext.getFormContext ();
    formContext.data.refresh (save) .then (successCallback, errorCallback);
    }
    catch (e)
    {
    alert ("Error in test function:" + e.message);
    }
    }

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Try following:

    function test (executionContext)

    {

    debugger;

    try

    {

    var formContext = executionContext.getFormContext ();

    formContext.data.refresh (true);

    }

    catch (e)

    {

    alert ("Error in test function:" + e.message);

    }

    }

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)
    {
    debugger;

    try
    {
    var formContext = executionContext.getFormContext ();
    formContext.data.refresh (true);
    }
    catch (e)
    {
    alert ("Error in test function:" + e.message);
    }
    }

    Thank you

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)
    {
    debugger;

    try
    {
    var formContext = executionContext.getFormContext ();
    formContext.data.refresh (true);
    }
    catch (e)
    {
    alert ("Error in test function:" + e.message);
    }
    }

    Thank you

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)

    {

    debugger;

    try

    {

    var formContext = executionContext.getFormContext ();

    formContext.data.refresh (true);

    }

    catch (e)

    {

    alert ("Error in test function:" + e.message);

    }

    }

    Thank you

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)

    {

    debugger;

    try

    {

    var formContext = executionContext.getFormContext ();

    formContext.data.refresh (true);

    }

    catch (e)

    {

    alert ("Error in test function:" + e.message);

    }

    }

    Thank you

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)

    {

    debugger;

    try

    {

    var formContext = executionContext.getFormContext ();

    formContext.data.refresh (true);

    }

    catch (e)

    {

    alert ("Error in test function:" + e.message);

    }

    }

    Thank you

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hello Andrew good morning,

    Thanks for the feedback.

    I put the code you gave me, it did not present any kind of error, but did not update the page.

    Theoretically every time the form is saved, reload the page because I have a javascript that calculates and updates Opportunity's estimated revenue.

    Follows code:

    function test (executionContext)

    {

    debugger;

    try

    {

    var formContext = executionContext.getFormContext ();

    formContext.data.refresh (true);

    }

    catch (e)

    {

    alert ("Error in test function:" + e.message);

    }

    }

    Thank you

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 70 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 44 Super User 2026 Season 2

#3
Subra Profile Picture

Subra 42 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans