Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Created May 6, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marcduiker/875644d239aa8a4259bb1e201b06f5c8 to your computer and use it in GitHub Desktop.
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.
$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