manoj´ssharepointblog

SharePoint Blog

This functionality is unavailable for field collections not associated with a list

Leave a comment

For my scenario the above issue occurs when I try to add a field to the content type i.e. when i use ContentType.AddField.

I have solved the above issue by using SPFieldLink instead of SPField

Below is code for your reference

SPContentType cDocumen = newSPContentType(null,Web.ContentTypes,“MyDocument”);

Web.ContentTypes.Add(cDocumen);

Web.Fields.Add(“Autor”, SPFieldType.Text, false);

SPFieldLink SPFLautor = newSPFieldLink(miWeb.Fields[“Autor”]);ctDocumento.FieldLinks.Add(SPFLautor);

cDocumen.Update();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s