0

I have a custom contenttype. This contenttype is inherited some columns from the OOTB contenttype "ArticlePage". I would like to set one of these columns required in my custom contenttype. How to do that programmatically? I am talking about the column "ArticleStartDate".

2
SPContentType contentType = curWeb.ContentTypes["Custom CT Name"];

SPField field = contentType.Fields["ArticleStartDate"];
contentType.FieldLinks[field.Id].Required = true;
contentType.Update();

Use the FieldLinks property of the contenty type. There are quite a lot of examples explaining using this property. Refer msdn as well : FieldLinks

  • "ArticleStartDate" is an internal name, I assume. So the code would be: contentType.Fields.GetFieldByInternalName("ArticleStartDate"); – Paul Strupeikis Sep 8 '15 at 7:50

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.