SharePoint Experts Blog

Deploy custom SharePoint 2013 workflows with site template

It is common scenario when you did some customizations, saved site as template and want to reuse it in SharePoint 2013. Such site templates can include workflows with custom workflow actions. Unfortunately if you save site with custom workflow actions as template and then try to create new site you can receive such annoying error:

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

The reason of such behavior is related to incorrect processing of template by SharePoint 2013. I described it in detail in other my blog article. But this article is not about reasons of such behavior. We created small utility program TemplatePackageFix which fixes site templates with custom workflow actions and allows to reuse them as many times as you need.

We decided to implement 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

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 direct link. For example:
https://yourSiteUrl/sites/WebUrl/_layouts/15/savetmpl.aspx

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).

When the operation will be completed, please download the WSP package from the solution gallery.

Click on the template to download it:

Patch the site template

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

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

To avoid the error we have to patch the WSP package with help of a small utility TemplatePackageFix. I described it in detail in my previous article. This utility simply moves all workflows to separate feature. Thus, 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 from the following link. Please download it and extract to any directory.

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

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:\YourFolder\TempatePackageFix.exe 

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

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 saved template

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

 

Then, scroll down and press “new subsite”:

Please fill all the fields and select your site template on “Custom” tab. Note, if you can’t find your site template, most likely you selected incorrect language.

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

Conclusion

I hope this small utility will save your time and simplify moving your customizations between farms and site collections. Should you have any questions feel free to comment.

Posted in: Products, Workflow Actions Pack

  • keti
    Hi, then I try to save site as template this error appear: Sorry, this site can’t be saved as a template. It contains apps that don’t work in templates: Forms Designerhow I can overrode it, (SharePoint online, office 365)
    • Roman Rylov
      Hi Kety, you need to remove the app and then you will be able save web as template.
  • Marc Nemegeer
    Hi, I tried this way of working and I’m not able to activate the modified wsp after uploading it. It complains about feature id’s that are not unique. Am I doing something wrong ? I’m using the Plumsail string actions, should I change the console app ?