Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to cast object of type 'Microsoft.SharePoint.Client.Field' to type 'Microsoft.SharePoint.Client.Taxonomy.TaxonomyField'. #1032

Open
josipgrgic opened this issue Jun 25, 2024 · 0 comments

Comments

@josipgrgic
Copy link

Hello PnP team,

I am facing this problem when extracting a template from an existing site. The stack trace is below:

"stackTrace": " at PnP.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractFields(Web web, List siteList, List1 contentTypeFields, ListInstance list, List1 lists, ProvisioningTemplateCreationInformation creationInfo, ProvisioningTemplate template)\r\n at PnP.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)\r\n at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)\r\n at Microsoft.SharePoint.Client.WebExtensions.GetProvisioningTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)\r\n at PnP.Framework.Provisioning.ObjectHandlers.ObjectHierarchySequenceSites.ExtractObjects(Tenant tenant, ProvisioningHierarchy hierarchy, ExtractConfiguration configuration)\r\n at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetTenantTemplate(Tenant tenant, ExtractConfiguration configuration)\r\n at Microsoft.SharePoint.Client.TenantExtensions.GetTenantTemplate(Tenant tenant, ExtractConfiguration configuration)\r\n

The exact line that fails is:
image

An identical issue was referenced in #830 and I believe the same fix can be applied here as well.

change
var taxField = (TaxonomyField)field;

to
var taxField = web.Context.CastTo<TaxonomyField>(field);

(it fixed my problems at least)

Best regards,
Josip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant