mercredi 17 décembre 2014

SharePoint 2013 Change default start time and end time on calendar event



We're scheduling a lot of similar events, so the start time is almost always 8:30AM and the end time is almost always 5:30PM (not necessarily on the same day). Is there any way that we can set the defaults for these through JavaScript? It doesn't necessarily have to be JS, we just can't use workflows to solve this problem because we do occasionally have events that need to happen at other times. A solution editing the NewForm.aspx would work as well if anyone has that. OOTB would be even better.


It looks like this (http://ift.tt/1wJ88pH) was written for SP2010. I used Firebug to inspect the labels for my time fields. They aren't actually "label" tags, they are "nobr" tags and do not have "for" attributes, so it appears that this solution is trying to access elements that SharePoint is no longer using.


I would just use the ID columns of the time boxes themselves, but they are some kind of generated code and and I'm worried that they won't always be the same. I have shown the generated code for the Start Time select box:



<select id="ctl00_ctl41_g_05eee1e1_a7d0_4b5e_9eb1_dc1e566ce47e_ctl00_ctl05_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDateHours" dir="ltr" name="ctl00$ctl41$g_05eee1e1_a7d0_4b5e_9eb1_dc1e566ce47e$ctl00$ctl05$ctl00$ctl00$ctl00$ctl04$ctl00$ctl00$DateTimeField$DateTimeFieldDateHours">
<option value="12 AM">12 AM</option>
<option value="1 AM">1 AM</option>
<option value="2 AM">2 AM</option>
...
<option value="11 AM">11 AM</option>
<option value="12 PM" selected="selected">12 PM</option>
<option value="1 PM">1 PM</option>
...
<option value="10 PM">10 PM</option>
<option value="11 PM">11 PM</option>
</select>


I need a way to set this that will always work and I suppose that if we know that the ID will always be the horrendously long string shown above, then I can just hard code that and get the element by its ID, but I don't know if it will be. Any advice?


Also, if it is important, I am using the modal window (and need to continue to do so).








0 commentaires:

Enregistrer un commentaire