Created
May 6, 2016 14:50
-
-
Save marcduiker/875644d239aa8a4259bb1e201b06f5c8 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