0

Like OOB,

Can we add Site Column to All Content Types using server object model?

Thanks

1

1 Answer 1

0

Try This

   SPList currentList = currentWeb.Lists["DocLib"];
   SPField newField = currentList.Fields.CreateNewField(SPFieldType.Text.ToString(), "New Field2");
   currentList.Fields.AddFieldAsXml(newField.SchemaXml, true, SPAddFieldOptions.AddToAllContentTypes);
   currentList.Update();

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.