1

We have a requirement for bulk workflow approval. Where we need to add items(with or without children) similar to this image,

enter image description here

Following this article, https://www.sitecorenutsbolts.net/2015/12/14/Multi-Item-Publish-with-Sitecore-Powershell-Extensions/, I created a power shell module named "BulkApproval" as below,

enter image description here

and when I click on Start new batch I was able to create a directory in the Data folder, now I am not sure how to copy the selected items to the newly created folder.

How do I achieve this? Any guidance would be much helpful.

My script is as below,

$dataFolder = [Sitecore.Configuration.Settings]::DataFolder
$rootFolder = $dataFolder + "\buckets"
$selectedItem = Get-Item -path .    
if($selectedItem -ne $null){
    $selectedItems = @()
    $newWorkflowName = Show-Input "Please provide a name for the new batch:" -MaxLength 20
    if($newWorkflowName -ne $null -and $newWorkflowName -ne ""){
        
        $selectedItems += $selectedItem
        if($selectedItem.Children.Length -gt 0){
                $includeChildrenPromptResult = Show-ModalDialog -Control "ConfirmChoice" -Parameters @{btn_0="Yes"; btn_1="No";  te="Include child items?"; cp="Create Batch and Add Item"} -Height 120 -Width 450
                if($includeChildrenPromptResult -eq "btn_0"){
                    $allChildItems = Get-ChildItem -Path $selectedItem.Paths.FullPath -Recurse
                    $selectedItems += $allChildItems
                   
                }
            }
    }
        #create a new directory here
        $newWorkflowPath = $rootFolder+"\"+$newWorkflowName
        Write-Host("$newWorkflowPath",$newWorkflowPath)
            Write-Host("New Item",$newWorkflowPath)
            New-Item -Path $newWorkflowPath -ItemType directory
ForEach ($item in $selectedItems) {
     Copy-Item -Path  $item.FullPath -Destination $newWorkflowPath
}   
    }
2
  • I don't know if you've considered all of your options, so please disregard this comment if you have! But, have you consider adding a new commands to the workbox, such as "Submit with children" & "Approve with children" to meet your requirements of "with or without children" the workbox supports without children out of the box.
    – dru_ward
    May 2, 2022 at 19:52
  • The requirement is not to add it to workbox. I have already referred an article on Batching the workflow. But that was not the requirement. May 2, 2022 at 21:00

1 Answer 1

0

I was able to copy the item to specified path using Export-item command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.