0

Currently when users schedule a work shift they are having to select a date on the form. Is there a way to capture the date when they select it from the calendar. You would think that it would already do that, or have it as an option since they selected the date in the first place.

Feedback and advice is appreciated. Thanks!

  • 1
    If you double-click a day on the calendar, does it open with the correct event date? I just tested this on SP2013 and SharePoint Online and verified that it works for me. – James Dec 29 '16 at 16:47
  • I created a new date and time field with the date only and it doesn't capture the date. It just gives a blank square when the form comes up. – cbbrown Dec 29 '16 at 19:21
  • Why did you need a new field? The Start Time field is a built-in field that is tied to this functionality. If you want your custom field to grab the selected date/time, you're going to need to write custom code to make that work (JavaScript). – James Dec 30 '16 at 14:06
  • Yeah, I went through and added a "Start Time" field, but I don't need the time part on there, and the field can't be edited to display Date Only. – cbbrown Dec 30 '16 at 14:30
0

You need to use the default Start Time field that is associated with the Event content type. You can use JavaScript to click the All Day Event checkbox, which removes the time portion of the date/time fields.

Edit your NewForm.aspx page (using SharePoint Designer or just in the browser), insert a Script Editor Web Part, and insert the code below.

// include jQuery
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
  $(function() {
    $('span[title=All Day Event] > input').attr("checked","checked"); // checks All Day Event
   //hide check-box
   $('tr:has(span[title=All Day Event])').not('tr:has(tr)').hide();
 });
</script>

Code taken from Set all day event default value

  • Sorry to bother you again, but I revisited this option and I need to go ahead and see if I can make it work. You mentioned that I need to edit the NewForm.aspx page. I have never done this before. What do I need to change? And is it in addition to the script editor web part? – cbbrown Jan 5 '17 at 20:17
  • If your New Item form for your calendar opens in a dialog window, disable that under List Settings > Advanced Settings > Dialogs. Then go to add a new item and you'll be taken to a full-page version of your NewForm.aspx page. Edit this page and insert the script editor as detailed in my answer. – James Jan 6 '17 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.