Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've made a custom Event type and am trying to figure out how to remove the Recurrence field from the build in SharePoint Event.

Here's my code, which doesn't seem to work :(

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <!-- Parent ContentType: Event (0x0102) -->
 <ContentType ID="0x0102003841e0a1067b4db29c0baa86c7301e96"
           Name="CountDownEvent15"
           Group="Custom Content Types"
           Description="My Content Type"
           Inherits="TRUE"
           Version="0"
           >
<FieldRefs>
  <RemoveFieldRef ID="{F2E63656-135E-4f1c-8FC2-CCBE74071901}" Name="fRecurrence" />
</FieldRefs>

Does anybody know how I might be able to remove the built in Recurrence field when creating a custom event?

share|improve this question
add comment

1 Answer

To answer my own question:

  1. You can't remove the Recurrence using the elements.xml - at least not this way.

  2. You can however remove it using the code below:

       using (SPSite site = new SPSite("http://MySharePointSite"))
       {
           using (SPWeb web = site.OpenWeb())
           {
               SPContentTypeCollection cts = web.ContentTypes;
               SPContentType ct = cts["MyContentType"];
               ct.FieldLinks.Delete("fRecurrence");
               ct.Update(true);
           }
       }  
    
  3. I'm going to change this code and place it in the FeatureActivate method.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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