2

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?

2

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.

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.