Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Update paginglimit in usersettings with javascript and refresh main grid

(0) ShareShare
ReportReport
Posted on by
Hi everybody,
i have a small problem with refreshing the main grid after javascript update paginglimit in usersettings entity. This is what i have done:
1) i created in ribbon a a dropdown with 5 command buttons. Each button has signed value, as you see on the picture.
2) I created and added javascript ressource. If use klick on one of 5 buttons, javascript will start. This code will get parameter from a button and pass it to JS as first parameter. Based on userId and this parameter a user settings will be updated.
function setROwsPerPage(rowsPerPage, selectedControl) {    console.log(/Start 6/);var userSettings = Xrm.Utility.getGlobalContext().userSettings;var currentuserid = userSettings.userId.replace(/{/, //).replace(/}/, //);var data = {/paginglimit/: rowsPerPage};// update the recordXrm.Utility.showProgressIndicator(/Benutzereinstellungen werden aktualisiert, bitte warten.../);Xrm.WebApi.updateRecord(/usersettings/, currentuserid, data).then(function success(result) {            console.log(/UserSettings updated/);              Xrm.Utility.closeProgressIndicator();            window.parent.location.reload(true);},function (error) {console.log(error.message);Xrm.Utility.closeProgressIndicator();});}
My problem is: this code work just ok but after the page is refreshed the number of rows per page has not changed. Changes are visible only, when i klick butto two times - First time it will update record and page, but the number of row on the screnn did not changen. After secord time the number on the screen did changen.
 
I tried with settimeout fo 5 and 10 seconds but it it not working. Is there any solution, how can i achive this? 
We do not wannt to go everytime into personal settings to change rows per page... it take too much time and we did it a couple of times per hour. 
  • Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    Update paginglimit in usersettings with javascript and refresh main grid
    Hi,
     
    I encountered the same issue as you when testing your code.
     
    When I try to manually refresh after removing this line of code.
    With hard refresh (ctrl+F5) you can change the number of rows per page at once. Whereas a normal refresh (F5) takes two times to change the number of rows per page.

    Therefore, it requires code that can implement a hard refresh to change the number of rows at a time.
     
    According to this documentation.
    Location: reload() method - Web APIs | MDN (mozilla.org)
    Pass true to force a reload bypassing the cache. Defaults to false. Only supported in Firefox.
    For all other browsers this method of refreshing is equivalent to a F5 refresh.
    ​​​​​​​
    Unfortunately, I didn't find code that would implement a hard refresh.
    Here are some links about hard refresh using JS.
    https://stackoverflow.com/questions/5721704/window-location-reload-with-clear-cache?noredirect=1&lq=1
    https://stackoverflow.com/questions/2099201/javascript-hard-refresh-of-current-page?noredirect=1&lq=1

    Best Regards,
    Dengliang Li
    ​​​​​​​
     

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans