Over the last few weeks I’ve been working with one of my customers to create sites from a site request list. For each new client that they register a new site request is created and then a SharePoint Designer workflow calls a service that will create a site collection and then after that a PnP template is applied.

Error: Value cannot be null. Parameter name: input

All quite easy stuff, however today I ran into a problem. I got the following error when a workflow was added to my site:

Error: Value cannot be null. Parameter name: input

When I tried to apply the templates using PnP PowerShell the template would simply work. So my templates are valid.

After a bit of debugging I found that the following lines in PnP Sites core’s objectWorkflows.cs are responsible for reading the workflow definition file:

// Load the Workflow Definition XAML
Stream xamlStream = template.Connector.GetFileStream(templateDefinition.XamlPath);
XElement xaml = XElement.Load(xamlStream);

The templateDefinition.XamlPath just contains the guid.xaml file name without any location

In this case I didn’t really want to add the path to my template xml file as that would be complicated to pass down to the pice of code that is running. Quite early on in the process the template is read and after that the file location is not relevant anymore.

SharePoint 2016 - PnP ApplyProvisioningTemplate - Error: Value cannot be null. Parameter name: input Microsoft Office 365

What to do next?

Within my web service I’m running:

web.ApplyProvisioningTemplate(template, provisioningTemplateApplyingInformation);

I’m simply changing my current directory to  the template file and now the PnP Sites Core libraries pick up my Workflow file:

web.ApplyProvisioningTemplate(template, provisioningTemplateApplyingInformation);

Why does this work with PnP PowerShell?

Within the PnP PowerShell code your path is adjusted while PnP-ProvisioningTemplate is running. This makes it possible to find the workflow file.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as a Principal Architect at HybrIT Services Ltd. You can contact me using contact@sharepains.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue Reading

%d bloggers like this: