Start SharePoint 2010 Workflow manager
-
19-12-2020 - |
문제
I have made a Powershell script to run workflow on SharePoint 2010. The workflow manager assignment is the only part of the script with a null value.
$listName = "Action Tracking System"
$Site = Get-SPsite "https://intranet.xxx.xxx.xxx/depts/FSO" | GEt-SPweb
$List = $Site[1].lists[$listname]
$manager = $site[1].workflowmanager
$Association = $list.WorkflowAssociations[5] #30 Day Reminder workflow
$association.AllowAsyncManualStart = $true
$association.AllowManual = $true
$data = $Association.AssociationData
foreach ($Item in $list.Items)
{
Write-Host " Content: " $Item.Name
$wf = $manager.StartWorkflow($Item,$association,$data)
}
$manager.Dispose()
It returns you cannot call a method on a null value expression (char 27).
The site is a subsite of FSO, the $site[1] index shows the correct site. How can I start this workflow?
해결책
The code is wrong. The following is what you need to start a SharePoint 2010 workflow.
$ListName = 'Action Tracking System';
$WorkflowName = '30 Day Reminder';
$Web = Get-SPWeb 'https://intranet.xxx.xxx.xxx/depts/FSO';
$List = $Web.Lists[$Listname];
$Items = $List.GetItems();
$Manager = $Web.Site.WorkflowManager;
$Association = $List.WorkflowAssociations.GetAssociationByName($WorkflowName, 'en-US');
$Data = $Association.AssociationData;
foreach ($Item in $Items)
{
Write-Host 'Content: ' $Item.Name;
$WF = $Manager.StartWorkflow($Item, $Association, $Data, $true);
}
$Manager.Dispose();
$Web.Dispose();
제휴하지 않습니다 sharepoint.stackexchange