views:

52

answers:

1

Thanks for the great help. Another question. How do I set my "All Day Event" field on the calendar to default to "Checked/Yes?" If we can set the default on All Day Event to Yes, is there a way to hide the time fields (keep the date fields - just no time fields)? I'd also like to hide the "Workspace" field as well (if possible).

Thank You

Dave M

A: 

If you have access to run code on your server, I've run this from a console application and it worked like a charm:

using(SPSite site = new SPSite("http://yoursite"))
{
  using(SPWeb web = site.OpenWeb())
  {
    SPList list = web.Lists["your list name"];
    SPContentType ct = list.ContentTypes["Event"];
    SPFieldLink fieldLink = ct.FieldLinks["fAllDayEvent"];
    Type type = typeof(SPFieldLink);
    PropertyInfo pi = type.GetProperty("Default", BindingFlags.NonPublic | BindingFlags.Instance);
    pi.SetValue(fieldLink, "1", null);
    ct.Update();
  }
} 

Source: http://pholpar.spaces.live.com/blog/cns!2CD45589973F2849!131.entry

Only modification we had to make was the SPFieldLink, the examples uses All Day Event, our lists used fAllDayEvent.

The only other way I've seen work is to modify the list's CAML (Example).

Oh, and we hid the Workspace field using Javascript:

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

_spBodyOnLoadFunctionNames.push("hideFields");

function fc(FieldName) {
   var arr = document.getElementsByTagName("!");

   for (var i=0;i < arr.length; i++ ) {
      if (arr[i].innerHTML.indexOf(FieldName) > 0) { return arr[i]; }
   }
}

function hideFields() {
   control = fc("Workspace");
   control.parentNode.parentNode.style.display="none";
}
</script>

Source: http://sharepointsherpa.com/2008/08/26/sharepoint-2007-hiding-fields-on-newformaspx-and-editformaspx-the-easy-way/

brianng

related questions