logo
Documents & Forms
Microsoft 365 & SharePoint Tools
Classic SharePoint Tools
Actions Pack
Nov 13, 2017

Deploy custom workflows with a site template

Customer Support Engineer

It is a common scenario when you do some customizations, save the site as a template and want to reuse it in SharePoint 2013 / 2016 / 2019 or in SharePoint Online (Microsoft 365). Such site templates can include workflows with custom workflow actions. Unfortunately, if you save a site with custom workflow actions as a template and then try to create a new site you can receive such annoying error:

Microsoft.Workflow.Client.ActivityNotFoundException:Theactivity 
named'WorkflowXaml_988fe3c3_dc3e_47a9_8ff3_c912c82eb56d'fromscope'
/spo/216722f1-1dc0-4c6d-aafd-86b12ef60a14/1f87e1ae-da77-44d4-92d1-502507b5f2d4/34ceaf02-5217-46be-a307-e09dd93da230'
wasnotfound.HTTP headers receivedfromthe server-ActivityId:224e672a-4e00-44ed-8b55-894a059608c2.
NodeId:.Scope:.ClientActivityId:f6cadd9c-c011-1000-aa42-85eedd28fc19.--->
System.Net.WebException:Theremote server returned an error

The reason for such behavior is related to the incorrect processing of template by SharePoint 2013.

That’s why it was implemented such utility because some of our customers had questions about correct site template provisioning. Especially when custom site template included workflow actions from our product Workflow Actions Pack.

Use case — deploy a new web with configured workflows

Save Site as Template

In the first step, you need to create a Site template. To do this navigate to Site Settings ->Save site as Template (In Site Actions section). If you don’t see this link you can navigate using the direct link. For example: https://yourSiteUrl/sites/WebUrl /_layouts/15/savetmpl.aspx

1

Then fill all the fields and check the checkbox “Include content” (If you don’t do this the workflows won’t be included into template).

2

When the operation is completed download the WSP package from the solution gallery.

3

Click on the template to download it.

Patch the site template

As described earlier if we try to create a new site we can get the following error:

Microsoft.Workflow.Client.ActivityNotFoundException:Theactivity 
named'WorkflowXaml_988fe3c3_dc3e_47a9_8ff3_c912c82eb56d'fromscope'
/spo/216722f1-1dc0-4c6d-aafd-86b12ef60a14/1f87e1ae-da77-44d4-92d1-502507b5f2d4/34ceaf02-5217-46be-a307-e09dd93da230'
wasnotfound.HTTP headers receivedfromthe server-ActivityId:224e672a-4e00-44ed-8b55-894a059608c2.
NodeId:.Scope:.ClientActivityId:f6cadd9c-c011-1000-aa42-85eedd28fc19.--->
System.Net.WebException:Theremote server returned an error

To avoid the error we have to patch the WSP package with help of a small utility TemplatePackageFix. The utility is described in detail in another article . It simply moves all workflows to a separate feature. Thus, a site will be created by template without workflows and then you will be able to activate the feature to deploy workflows.

You can download it here and then extract to any directory.

To run, press “Win + R” and run the CMD.

4

Next step is to specify path to the program and path to the WSP package which we downloaded. The command can look like this:

c:YourFolderTempatePackageFix.exe

After a few seconds you will see “fixed” message:

5

That is all. Your WSP package has been patched, all workflows have been moved to another feature. The last step is to upload the WSP package to the solution gallery.

Create new Site based on a saved template

Now you can upload the patched wps package with the site template to your solution gallery and activate it. Then, you can create a new site. To do this navigate to “Site Contents”.

6

Then, scroll down and press “new subsite”:

7

Fill all the fields and select your site template in the “Custom” tab. Note, if you can’t find your site template most likely you have selected an incorrect language.

8

The last step before you can use the site, is to activate the “Workflow Actions Pack” feature (this will make available custom workflow actions) and “Template workflows” feature (it contains all your workflows).

9

Note: The post has been originally published at Medium: