Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

Auto Refresh Page View using JavaScript

(0) ShareShare
ReportReport
Posted on by 35

Hello experts,

I want to refresh the Page on success of dialogue box Button click in JavaScript.

I tried to solve it  by using 

  1. parent.Xrm.Page.data.refresh(true);
  2. Xrm.Page.data.refresh(true);
  3. window.refresh();

but, all of this won't refresh the view and unselected the selected record.

so is there any way, to reload the page, or auto click the refresh button.

Here is my part of Code, where i am using refresh page function

var error = JSON.parse(this.response).error;
                Xrm.Navigation.openErrorDialog({ message: error.message}).then(
                function(success) 
                { 
                    setTimeout(function () {
                        parent.Xrm.Page.data.refresh(true);
                    }, 500);
                    
                }, 
                function (error) 
                { 
                    console.log(error); 
                    setTimeout(function () {
                        parent.Xrm.Page.data.refresh(true);
                    },800);
                    
                });
  • Suggested answer
    YK-20091704-0 Profile Picture
    3 on at
    Auto Refresh Page View using JavaScript
    Unsupported way worked for me!
  • Abhilash M abi Profile Picture
    595 on at
    RE: Auto Refresh Page View using JavaScript

    Clofly Mao Thanks a lot. I tried supported way and it worked.

  • cloflyMao Profile Picture
    25,208 on at
    RE: Auto Refresh Page View using JavaScript

    Hi Anubha,

    It is very glad that your problem has been solved.

    If you had found any answer helped, please kindly mark as verified to close the thread, it would be really appreciated.

    Regards,

    Clofly

  • Anubha Soni Profile Picture
    35 on at
    RE: Auto Refresh Page View using JavaScript

    Exact and proper Solution. Thank you so much

  • Anubha Soni Profile Picture
    35 on at
    RE: Auto Refresh Page View using JavaScript

    Thank you so so much, your help made a great change. Thank you it is working perfectly fine.

  • Verified answer
    cloflyMao Profile Picture
    25,208 on at
    RE: Auto Refresh Page View using JavaScript

    Hi Anubha,

    There are only 3 elements that have aria-label="Refresh" attribute, the start index is 0. So the range is from 0 to 2.

    pastedimage1603372612289v1.png

    Try executing parent.document.querySelectorAll('[aria-label="Refresh"]')[2].click(); to check whether it could refresh view.(I tested and it works.)

    123.gif

    Regards,

    Clofly

  • Anubha Soni Profile Picture
    35 on at
    RE: Auto Refresh Page View using JavaScript

    Screenshot-2020_2D00_10_2D00_22-182845.pngThank you so much for your reply,

    Can you please tell me how to resolve that issue which i am facing.

  • Suggested answer
    cloflyMao Profile Picture
    25,208 on at
    RE: Auto Refresh Page View using JavaScript

    Hi Anubha,

    Thanks for sharing details.

    You can do it following two approaches:

    1. The unsupported way:

    As what I said in my first answer, fire the click event of refresh button element manually.

    parent.document.querySelectorAll('[aria-label="Refresh"]')[0].click();

    2. Supported way:

    Pass SelectedControl parameter to command of your custom button.

    pastedimage1603264049698v1.png

    Then we can refresh the view with such syntax:

     selectedControl.refresh(); 

    function test(selectedControl) {
      selectedControl.refresh(); 
    }

    Please refer to the article:

    https://nemely.com/blog/refresh-crm-grid-using-javascript/

    I tested the method and it works!

    chrome_2D00_capture.gif

    Regards,

    Clofly

  • Anubha Soni Profile Picture
    35 on at
    RE: Auto Refresh Page View using JavaScript

    Hi expert,

    here is my page, which i want to auto refresh.

    5023.pastedimage1603193773045v1.png

    Thank!

    Anubha Soni

  • cloflyMao Profile Picture
    25,208 on at
    RE: Auto Refresh Page View using JavaScript

    Hi Anubha,

    Could you share a screenshot of "the Page View of an Entity"?

    Regards,

    Clofly

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans