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

When using the sharepoint api to add field links to a content type, with code similar to the following:

AddFieldLink(siteField, contentype);    
contentype.Update(true, true);

I have specified true, in the update method to ensure that the field is mandatory. When I then edit an item of this content type in the UI will it ensure that this field contains a value i.e. will the field for this meta data be mandatory?

all the best

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

The update method is only performing the action of saving the changes to this content type (and optionally and children it may have), it does not set any properties on individual FieldLinks.

The first boolean in the update method will simply force the update to all child content types and the second one tells SP to throw an exception if it finds a child CT which it can not update.

You would need to set the required property on the SPFieldLink.

Dim fieldLink As SPFieldLink = contentType.FieldLinks(field.Id)
fieldLink.Required = True

This is also how you could set ReadOnly or Hidden properties for this field within your content type.

fieldLink.ReadOnly = True
fieldLink.Hidden = False
share|improve this answer
add comment

Your Answer

 
discard

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