locked
How to refresh screen after updating value RRS feed

  • Question

  • Hi,

    How can I let a plugin refresh my screen?

    I have a custom entity and this custom entity has an 1:N-relation with another custom entity (let's call it a sub-entity). When a sub-entity is created or update, the plugin counts the number of sub-entities and places the number of entities on a field on the sub-entity.

    It's all working fine, except that I have to manually hit CTRL+F5 (refresh) to see the new values.

    Isn't there a handy line of C#-code for this?

    Regards, Leonard

    Monday, July 26, 2010 2:19 PM

Answers

All replies

  • You can't achieve that with plugins as plugins are executed on a server side.

    But you should be able to put some javascript code on the onsave or onload event of your sub entity form to refresh the parent form


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    • Marked as answer by Leonard_Str Tuesday, July 27, 2010 12:24 PM
    Monday, July 26, 2010 2:30 PM
    Moderator
  • You need some JScript on client side to refresh the parent entity form on save event. Something like; 

     

    window.opener.location.reload();
    

     

    There is another solution by Andriy also;

    http://a33ik.blogspot.com/2009/05/page-refresh.html


    MS CRM MVP :: uMar Khan :: Microsoft CRM Consultant (Blog :: http://umarkhan.wordpress.com)
    Monday, July 26, 2010 2:32 PM
    Moderator
  • Just a point about refreshing the parent window. If a previous action posted some data on the parent form, reloading it will ask to repost the same data again.

    That can be annoying and dangerous if your server side code updated the same data that were posted by the previous form action...

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Monday, July 26, 2010 2:38 PM
    Moderator
  • You might be able to use cookies to achieve your goal i.e. On the child form create a cookie when the sub - entity is saved. On the parent form attach to the window focus event and do a refresh if it finds its corresponding cookie. Don’t forget to delete the cookie or set proper timing

     


    GI CRM Blog * GI Website
    Monday, July 26, 2010 4:39 PM
  • A combination of setInterval and FetchXML should do the trick. Set the interval to 5-10 seconds and have the JS query the Webservice for the latest count.
    Monday, July 26, 2010 8:24 PM