Quantcast
Channel: SharePoint – SharePointed
Viewing all articles
Browse latest Browse all 69

SOLVED: Exception calling “StartWorkflow” with “X” argument(s)

$
0
0

Trying to start a SharePoint workflow using PowerShell and I couldn’t get past this error:

Exception calling “StartWorkflow” with “4” argument(s): “Object reference not set to an instance of an object.”

or

Exception calling “StartWorkflow” with “3” argument(s): “Object reference not set to an instance of an object.”

 

NO clue if there is a bug in my farm, but the script below works.  Ended up having to re-get the item when running the workflow. $manager.StartWorkflow($list.GetItemById($item.ID),$assoc,$data,$true)

$web = Get-SPWeb "http://rootSiteCollection.com"
$list = $web.Lists["Shared Documents"]

$assoc = $list.WorkFlowAssociations |Where { $_.Name -eq "tacoWF"}
$data = $assoc.AssociationData
$manager = $web.Site.WorkflowManager

$sQuery = New-Object Microsoft.SharePoint.SPQuery 

#Get all items with an ID greater than 5 
$caml = '<Where><Gt><FieldRef Name="ID" /><Value Type="Counter">5</Value></Gt></Where>'
$sQuery.Query = $caml
$fItems = $list.GetItems($sQuery)

Foreach($item in $fItems)
{
	$manager.StartWorkflow($list.GetItemById($item.ID),$assoc,$data,$true)
}

 


Viewing all articles
Browse latest Browse all 69

Trending Articles