Forked from marcduiker/Update workflow for all items.ps1
Created
July 23, 2016 12:59
-
-
Save jdylanmc/ca63ddfd61daea6ffcd69f136ea3aca7 to your computer and use it in GitHub Desktop.
Sitecore PowerShell action to update the workflow and workflow state for all items in the ListView of the report.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$processedItems = New-Object System.Collections.ArrayList | |
function SetWorkFlowAndState { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[Sitecore.Data.Items.Item]$Item, | |
[Parameter(Mandatory=$true)] | |
[Sitecore.Data.ID]$WorkflowID, | |
[Parameter(Mandatory=$true)] | |
[Sitecore.Data.ID]$WorkflowStateID | |
) | |
$Item.__Workflow = $WorkflowID | |
$Item."__Workflow state" = $WorkflowStateID | |
$processedItems.Add($item) > $null # ignore output of Add | |
} | |
foreach ($item in $allData) { | |
SetWorkFlowAndState $item $actionData.WorkflowID $actionData.WorkflowStateID | |
} | |
if($scriptsession.Output.HasErrors) { | |
Show-Result -Text | |
} | |
$processedItems | Update-ListView | |
Show-Alert -Title "Processed $($processedItems.Count) items." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment