Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

Using workflow for all site / subsites documents ???

$
0
0

Hello,

Is-it possible to apply a workflow to all documents (site and subsites) ?

I created a reusable workflow who works well in just one site for now but i would like to apply it on each futur subsite created automatically by powershell. 

I'm currently trying wsp package deployment for each subsites but when i try to manually associate the workflow to a list, i do not see it in "Select Workflow Template"

Powershell part for adding wsp + association to list

#Include the additional dll references required

[Void] [System.Reflection.Assembly]:: LoadWithPartialName("System")

[Void] [System.Reflection.Assembly]:: LoadWithPartialName("Microsoft.SharePoint.Workflow")

#open the web

$web = Get-SPWeb "http://site/subsite"

#list to which the workflow is to be associated

$list=$web.Lists["List"];

#create workflow association object

$culture=new-object System.Globalization.CultureInfo("en-US");

$basetemplate = $web.WorkflowTemplates.GetTemplateByName("Workflow test",$culture);

$wftasklist=$web.Lists["Workflow Tasks"];

$wfhistorylist=$web.Lists["Workflow History"];

$wfAssoc=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]:: CreateListAssociation($basetemplate,"list",$wftasklist,$wfhistorylist);

#associate workflow to list

$list.AddWorkflowAssociation($wfAssoc);

$list.Update();

#cleanup and end

$web.Dispose();

Error :

Exception calling "CreateListAssociation" with "4" argument(s): "Value cannot
be null."
At line:1 char:1
+ $wfAssoc=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::
CreateListAssoc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

$basetemplate is empty

If anyone can help me.

thank you !!



Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>