You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can successfully create content types but the ContentType field is not correctly set when I use the content types to create documents in a document library.
Steps to reproduce
Context is a document library with an additional column "ContentType" added to the default view.
Then in code:
Create a site content type "CT1"
Upload a template files to the "Site Assets" library ("templatedoc1.docx")
Correctly assign the newly uploaded "templatedoc1.docx" to the content type "CT1"
Allocate the "CT1" content type to the Document library (ensuring content types is enabled on the document library)
Correctly see the content type "CT1" on the "New" menu of the document library
Create a second site content type "CT2"
Upload a template files to the "Site Assets" library ("templatedoc2.docx")
Correctly assign the newly uploaded "templatedoc2.docx" to the content type "CT2"
Allocate the "CT2" content type to the Document library
Correctly see the content type "CT2" on the "New" menu of the document library.
Remove the "Document" content type from the document library
If I create a content item using the "New > CT1" content type. The item is created with the content from "Templatedoc1.docx" When it gets saved it correctly sets the "ContentType" field to "CT1"
If i create an item using the "New > CT2" content type. The item is created with the correct content from "Templatedoc2.docx". When it gets saved though it gets set INCORRECTLY To "CT1"
Expected behavior
Creating a document from a content type with a template will correctly set the ContentType field. So in my example I expect the second document to have the "ContentType" field set to "CT2"
DELETE THIS LINE BEFORE SUBMITTING - Complete the following (if ignored you'll be prompted for it before we can address your issue... save the time and provide it in your initial submission).
SDK version: 1.14.0
OS: Windows 11
SDK used in: Console App
Framework: .NET 8.0
Browser(s): Edge Version 128.0.2739.42 (Official build) (64-bit)
Tooling: Visual Studio 2020 17.11
Additional context
The target site is a CLASSIC Team Site created from template STS#0
It I try to manually set the content type after creation I get the error message:
Error: The file is locked for shared use by [mylogin]
If I go to the document library > Library Settings > More Library settings
Select the document type then > Advanced settings
I see the correct path to the template document:
/sites/{mysite}/SiteAssets/TemplateDoc1.docx
If I use the "Upload the new document template" and select the file to upload manually and then create the items it all works correctly and the content type is allocated correctly.
If I do the same manual process for the content type at the SITE level it also works correctly and allocates the correct content type when an item is created.
I really want to know how I can programatically "Upload a new document template" in pnp.Core. (There are no examples)
Thanks for your contribution! Sharing is caring.
The text was updated successfully, but these errors were encountered:
metkhoo
changed the title
Uploading a file to a site content type does not set the Content type field correctly
Uploading a file to a site content type does not set the Content type field correctly (locks template file)
Sep 2, 2024
@metkhoo : did you test this with CSOM as well? Wondering if you see the same behavior? So setting the DocumentTemplateUrl on the created contenttypes is not working?
Category
I can successfully create content types but the ContentType field is not correctly set when I use the content types to create documents in a document library.
Steps to reproduce
Context is a document library with an additional column "ContentType" added to the default view.
Then in code:
If I create a content item using the "New > CT1" content type. The item is created with the content from "Templatedoc1.docx" When it gets saved it correctly sets the "ContentType" field to "CT1"
If i create an item using the "New > CT2" content type. The item is created with the correct content from "Templatedoc2.docx". When it gets saved though it gets set INCORRECTLY To "CT1"
Expected behavior
Creating a document from a content type with a template will correctly set the ContentType field. So in my example I expect the second document to have the "ContentType" field set to "CT2"
Environment details (development & target environment)
SDK version: 1.14.0
OS: Windows 11
SDK used in: Console App
Framework: .NET 8.0
Browser(s): Edge Version 128.0.2739.42 (Official build) (64-bit)
Tooling: Visual Studio 2020 17.11
Additional context
The target site is a CLASSIC Team Site created from template STS#0
It I try to manually set the content type after creation I get the error message:
Error: The file is locked for shared use by [mylogin]
If I go to the document library > Library Settings > More Library settings
Select the document type then > Advanced settings
I see the correct path to the template document:
/sites/{mysite}/SiteAssets/TemplateDoc1.docx
If I use the "Upload the new document template" and select the file to upload manually and then create the items it all works correctly and the content type is allocated correctly.
If I do the same manual process for the content type at the SITE level it also works correctly and allocates the correct content type when an item is created.
I really want to know how I can programatically "Upload a new document template" in pnp.Core. (There are no examples)
Thanks for your contribution! Sharing is caring.
The text was updated successfully, but these errors were encountered: