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".

1 Answer 1

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

1
  • "ArticleStartDate" is an internal name, I assume. So the code would be: contentType.Fields.GetFieldByInternalName("ArticleStartDate"); Commented Sep 8, 2015 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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