Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jdylanmc/ca63ddfd61daea6ffcd69f136ea3aca7 to your computer and use it in GitHub Desktop.
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.
$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