locked
How to auto refresh calendar page! RRS feed

  • Question

  • Hello,

    I have a query(weird) from one of our clients. Is it possible to auto-refresh the sharepoint calendar once a user posts an event?

    I know we can do it in a web part and can also write some java script to auto refresh the page within some time duration. But would like to know how to refresh the page once a event has been updated

    Please suggest


    Thanks & Regards, Chandra Shekhar

    Monday, May 14, 2012 10:54 AM

Answers

  • In essence, what your client is requesting is "push" technology where the server knows how to reach out to its clients (the browser) to notify that something has happened.  I do not believe that this is directly possible with OOTB browsers, and is impractical as it might not scale well.  

    One approach to mimic push would be to poll a "last calendar update" list item using Javascript from the browser against the SharePoint lists web service.  I like jQuery and SPServices, but you could also use the SharePoint Client Object Model on the browser side.  For the server side, you could set the "last calendar update" list item using an Event Receiver or by using a workflow that fires every time a new item (event) is added to the calendar.  The poll from the browser would use AJAX so that there would not be any refresh unless the time of the last server update is more recent than the last refresh.  You could set the poll to occur every 15 seconds or whatever seems reasonable.

    Even better:
    You could set the web service request to return one row (read a single list event) from the calendar list ordered by created (for add items) or modified (for edited calendar items) descending (so that the most recent is first) to determine the last add or update.  This would eliminate the need for an event receiver or workflow on the server.


    AndyGett Blog | @AndyGett Twitter


    • Proposed as answer by Aviw_ Tuesday, May 15, 2012 5:34 AM
    • Edited by AndyGett Tuesday, May 15, 2012 2:18 PM Even better: eliminate server work
    • Marked as answer by Steven AndrewsEditor Monday, May 21, 2012 11:16 AM
    Tuesday, May 15, 2012 4:59 AM

All replies

  • Out of the box you could enable the "Enable Asynchronous Automatic Refresh" for a set period of seconds on the Calendar web part. 

    Paul Turner http://redmanta.co.uk/blog Twitter: @RedMantaUK MCTS:WSS,MOSS,2010 MCITP:2010.
    Please remember to click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    Monday, May 14, 2012 11:50 AM
  • Hello,

    As I already mentioned I can do it using web part. What I wanted to know is how to auto refresh the page when the events are created.

    Please suggest


    Thanks & Regards, Chandra Shekhar

    Monday, May 14, 2012 2:16 PM
  • That would make it much more complicated and result in higher traffic requests to the server. I recommend using Paul's suggestion.

    -victor

    Be a part of the community, please remember to indicate if your question/comment has been answered or is helpful.

    Monday, May 14, 2012 3:00 PM
  • Hello,

    @Victor: Yes I already suggested the user, but he wants that functionality. So please suggest how to do it


    Thanks & Regards, Chandra Shekhar

    Monday, May 14, 2012 3:36 PM
  • In essence, what your client is requesting is "push" technology where the server knows how to reach out to its clients (the browser) to notify that something has happened.  I do not believe that this is directly possible with OOTB browsers, and is impractical as it might not scale well.  

    One approach to mimic push would be to poll a "last calendar update" list item using Javascript from the browser against the SharePoint lists web service.  I like jQuery and SPServices, but you could also use the SharePoint Client Object Model on the browser side.  For the server side, you could set the "last calendar update" list item using an Event Receiver or by using a workflow that fires every time a new item (event) is added to the calendar.  The poll from the browser would use AJAX so that there would not be any refresh unless the time of the last server update is more recent than the last refresh.  You could set the poll to occur every 15 seconds or whatever seems reasonable.

    Even better:
    You could set the web service request to return one row (read a single list event) from the calendar list ordered by created (for add items) or modified (for edited calendar items) descending (so that the most recent is first) to determine the last add or update.  This would eliminate the need for an event receiver or workflow on the server.


    AndyGett Blog | @AndyGett Twitter


    • Proposed as answer by Aviw_ Tuesday, May 15, 2012 5:34 AM
    • Edited by AndyGett Tuesday, May 15, 2012 2:18 PM Even better: eliminate server work
    • Marked as answer by Steven AndrewsEditor Monday, May 21, 2012 11:16 AM
    Tuesday, May 15, 2012 4:59 AM
  • Just to explain, I've unproposed Paul's post as Shekhar has advised it doesn't meet his client's needs.  I'm happy that it's a technical asnwer generally but it doesn't meet the OP's needs hence my unmarking it.

    Steven Andrews | SharePoint Professional | http://www.twitter.com/backpackerd00d | https://baron72.wordpress.com/


    Tuesday, May 15, 2012 1:49 PM
    Answerer