pnp / sp-dev-site-scripts

Repository for sample SharePoint site designs and site scripts
https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-overview
MIT License
162 stars 68 forks source link

Site columns added to a library are automatically added to list content type #47

Open ingrid-schiele-fnt opened 3 years ago

ingrid-schiele-fnt commented 3 years ago

Category

Expected or Desired Behavior

When I add content types via addContentType subaction to a library I only want to get those site columns assigned to the content type that are defined in the createContentType action.

Observed Behavior

But unfortunately when I have a look at my library, all site columns, that I've added to the library where assigned to the content type automatically. Thats really annoying as I use some hidden site columns for data handling that shouldn't be visible to the end-user.

Steps to Reproduce

Define a content type with the createContentType action. Add it to a library via addContentType subaction. After that use the addSiteColumn subaction to add some more site columns, that are not a part of the content type previously defined. Invoke the script and have a look at the libraries settings > columns section. As you can see, all columns are now part of the content type even if they were not defined to be so.

ingrid-schiele-fnt commented 3 years ago

It seems that the fieldOptions property is missing when processing the subaction. https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee542202(v=office.15) I've testet it with a Restapi Call via Flow and it works with the correct Options

POST SiteUrl _api/web/lists/GetByTitle('Authoring Library')/Fields/createfieldasxml Header: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose" } Body { "parameters": { "__metadata": { "type": "SP.XmlSchemaFieldCreationInformation" }, "Options": 10, "SchemaXml": '@{outputs('Doc_State_Schema_Xml')}' } }