0

i am able to create a new field in a sharepoint list using the "createfieldasxml" method of "fields" endpoint. There is a way to add this field to all content type, and not just to the default content type? The other way i thought is to add manually every field i need to all the content type, but it's not the best solution. I did not find in the documentation that parameter, but it is present in the csom approach.

Thanks

  • Does this link help - https://sharepoint.stackexchange.com/questions/158224/creating-site-column-and-add-it-to-content-type – Vineet Desai Sep 06 '21 at 16:19
  • Unfortunately no, because this is the csom approach that i can't use – Ghostmaster Sep 06 '21 at 16:25
  • Add a content type field reference to collection - https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245869(v=office.15)?redirectedfrom=MSDN . Don't miss the limitations towards the end of the article. – Vineet Desai Sep 06 '21 at 16:32
  • Yes, i know that i can do this way. Since i need to do this for 20 fields, I asked if there's a way to do in a single call when i create these fields, like in the interface where there is a "add to all content type" box – Ghostmaster Sep 06 '21 at 17:58
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 12 '21 at 06:34

1 Answers1

0

I answered you question here: https://learn.microsoft.com/en-us/answers/questions/541651/sharepoint-rest-api-create-field-and-add-to-all-co.html

You could set the Options property to 4(AddToAllContentTypes) in the body using createfieldasxml method like the below:

 {
   "parameters": {
     "__metadata": {
       "type": "SP.XmlSchemaFieldCreationInformation"
     },
     "SchemaXml": "<Field Type='Text' DisplayName='test' Name='test'></Field>",
     "Options":4
   }
 } 

The AddFieldOptions value can be found here: https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee542202(v=office.15)

Michael Han
  • 3,475
  • 1
  • 6
  • 8