Office 365. Cannot Convert Object Problem when provisioning pnp:File Display Template

Introduction

When we are using PnP Provisioning Core Engine to deploy SharePoint artifacts, we probably need to deploy Display Templates.

My colleague Kevin posted this blog post about this: http://sharepointcookies.com/2015/07/working-with-display-templates-with-the-new-pnp-provisioning-core-engine/.

Problem

But, some changes has been done in the PnP Provisioning Code and we need to adjust a little bit the code.

I am using PnP Version (v2.4.1605):

image

 

Here is the error received when I tried to provision Display Templates:

1
2
3
4
5
6
7
8
9
Cannot convert object of type 'System.Int32' to type 'System.String[]'
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectFiles.SetFileProperties(File file, IDictionary`2 properties, Boolean checkoutIfRequired)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectFiles.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo)
at Microsoft.SharePoint.Client.WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation)

clip_image001

 

Solution

Note that the problem where two properties: UIVersion and TargetControlType and the workaround was to wrap them into string array.

 

Author: José Quinto
Link: https://blog.josequinto.com/2016/06/14/office-365-cannot-convert-object-problem-when-provisioning-pnpfile-display-template/
Copyright Notice: All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.