none
How to set END date to be same Start Date? RRS feed

  • Question

  • The start and end date columns are set to TODAY's date.

    When user modifies the START to be (less than or more than today's date), the END date should not change as it does in outlook calendars. Is there anything to be setup for this in OOB? 

    If not, has anyone found a way to get this working. Is customization required here ? Can someone share their thoughts please? 

    TIA.
    Monday, November 3, 2008 10:09 PM

Answers

  • Hi,

    Yes, you want it to work like Outlook.  You'll want to use JavaScript that's incorporated into the NewForm and EditForm.aspx.  I haven't done this specific thing, but you should be able to find something that's close.  I'd recommend checking out the Microsoft SharePoint Designer Team Blog for lots of JavaScript examples.  http://blogs.msdn.com/sharepointdesigner/default.aspx.

    For a clever workaround (at least addressing that start comes before end), you might find this other forum article useful:
    http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/a5f0c402-8b16-4acf-b9a1-b1a5ab58dca2/


    Randy - http://sharepointhawaii.com/randywilliams
    • Marked as answer by JoshiP Tuesday, November 4, 2008 10:29 PM
    Tuesday, November 4, 2008 5:58 PM
  • Can be achieved with some client side javascript. I suggest you do the following:

    1. Open NewItem.aspx page for the calendar list in sharepoint designer.
    2. Insert script block for javascript within contentplaceholdermain.

    which is like


    <script language="javascript" type="text/javascript" id="javascript">

    _spBodyOnLoadFunctionNames.push("OnLoad");

    function OnLoad()
    {
        //logic goes here

    }

    </script>

    3. Within the logic section, find the input control for the startDate. and Assign onBlur event handler.

    4. within the onlbur event handler function, find the start time hours and start time minutes values from the respective select controls and set the value accordingly after your calculation to end time hours and end time minutes select control.

    --the entire procedure is easy if you are comfortable with javascripting to access right control on a page.--

    Thanks!


    sNjY
    • Marked as answer by JoshiP Tuesday, November 18, 2008 3:10 PM
    Wednesday, November 12, 2008 10:44 PM

All replies

  • Hi,

    Just trying to understand what want.  It's not how I read your post, but I assume you want the same behavior as Outlook when creating or editing a calendar list entry. 

    As you have noticed, the OOB behavior is there is no real logic to synchronizing the start/end dates.  Yes customization could do this.  Your best bet would be to customize this using JavaScript via SharePoint Designer.  The drawback is that you would need to do this for each and every calendar list. 

    Another approach is you could use a Custom Event Handler.  The advantage is that you could using a feature easily associate it will all your calendar lists (where the feature is enabled).  The drawback is that the change would be made silently after the user saves.  IMO, this is not good as it would could cause real confusion if the on screen value ends up changing "mysteriously."

    Hope this helps.
    Randy - http://sharepointhawaii.com/randywilliams
    Monday, November 3, 2008 11:42 PM
  • Thanks Randy,

    Yes it is to do with Start/End Dates.

    What is happening now is when user comes to create new appointment, both start & end date will have today's date. Then the user changes the start date to be something else and by mistake if he doesn't change END date (which should be greater than Start_date), what happens upon save is StartDate becomes EndDate and vice-versa.

    It will be helpful if you can provide me some example on the customization part.

    Appreciate your inputs.
    Tuesday, November 4, 2008 1:37 PM
  • Hi,

    Yes, you want it to work like Outlook.  You'll want to use JavaScript that's incorporated into the NewForm and EditForm.aspx.  I haven't done this specific thing, but you should be able to find something that's close.  I'd recommend checking out the Microsoft SharePoint Designer Team Blog for lots of JavaScript examples.  http://blogs.msdn.com/sharepointdesigner/default.aspx.

    For a clever workaround (at least addressing that start comes before end), you might find this other forum article useful:
    http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/a5f0c402-8b16-4acf-b9a1-b1a5ab58dca2/


    Randy - http://sharepointhawaii.com/randywilliams
    • Marked as answer by JoshiP Tuesday, November 4, 2008 10:29 PM
    Tuesday, November 4, 2008 5:58 PM
  • Not able to find suitable javascript functions so far..

    I want the END DATE to be set same as START Date after user exits from START-DATE field. Similary the timing on END-DATE should be 30min more than the timing specified on START-DATE.

    Appreciate your inputs.

    • Edited by JoshiP Wednesday, November 12, 2008 4:48 PM Modified contents.
    Tuesday, November 4, 2008 10:37 PM
  •  Can someone guide me?
    Wednesday, November 12, 2008 4:55 PM
  • Are you refering to Calendar list in sharepoint?

    and is it that you want to manipulate end date value before save while creating a new calendar item?

    thanks!
    sNjY
    Wednesday, November 12, 2008 8:05 PM
  • Yes. It is calendar list.

    I want EndDate to be same as Start Date (as soon as user  tabs out of Start Date) and the time (after EndDate) to be plus 30min that of the StartDate timings.

    Please reply.

    TIA
    Wednesday, November 12, 2008 8:46 PM
  • Can be achieved with some client side javascript. I suggest you do the following:

    1. Open NewItem.aspx page for the calendar list in sharepoint designer.
    2. Insert script block for javascript within contentplaceholdermain.

    which is like


    <script language="javascript" type="text/javascript" id="javascript">

    _spBodyOnLoadFunctionNames.push("OnLoad");

    function OnLoad()
    {
        //logic goes here

    }

    </script>

    3. Within the logic section, find the input control for the startDate. and Assign onBlur event handler.

    4. within the onlbur event handler function, find the start time hours and start time minutes values from the respective select controls and set the value accordingly after your calculation to end time hours and end time minutes select control.

    --the entire procedure is easy if you are comfortable with javascripting to access right control on a page.--

    Thanks!


    sNjY
    • Marked as answer by JoshiP Tuesday, November 18, 2008 3:10 PM
    Wednesday, November 12, 2008 10:44 PM
  • Hi sNjY,

    Sorry for late reply. I am following some of your steps but got few questions.

    - I believe I need to customize the newform.aspx (by making a copy as backup) before doing the above steps? IF so, will the USERS be able to go the same list and add/edit sharepoint columns out-of-box?.  If USERS can't do it, I believe I can add it using SPD? 

    Also, I belive above function does for OnLoad, So does it mean on page load it takes the StartDate ( including time) and then adds as per my calculation. I wanted the End date to be same as StartDate (after user tabs out from StartDate) and the time in EndDate to be plus 30mins of the time specified in StartDate.

    Many thanks.
    Tuesday, November 18, 2008 3:14 PM
  • Yes, its newform.aspx, sorry i wrote newitem.aspx...


    Users can still be able to add/remove columns for the list out of the box.

    and with this customization, you are going to attach a javascript fucntion to fire onLoad and the function will find the startDate text control and attach onBlur event to it so that the event can take care of the calculation and setting of end date whenever the focus is lost from start date.

    thanks!

     


    sNjY
    Tuesday, November 18, 2008 4:11 PM
  • Hi sNjy,

    Not getting good examples on onBlur.. Do you know any links?
    Tuesday, November 18, 2008 5:16 PM
  • Hi

    I have the same problem, does someone has found an easy solution?
    I would like to set the end date at the same date as the start time, and I haven't managed to do it with javascript.

    Thanks
    Wednesday, January 21, 2009 10:38 AM