We're using Sitecore PowerShell Extensions to generate some reports.

We have a problem when calling "Show-ListView" from the "Actions" script that is in the parent "Show-ListView" result.

Looks that both PowerShellResultViewerList sharing the same "Property" definition. We have same columns in both results, even if we defined different ones.

Our scenario:

  1. Select content item in the content editor
  2. Execute custom power-shell script from the ribbon with command (columns: Name, ItemPath, Notification):

    $reportItems | Show-ListView -ViewName "MyView" -ActionData $actionData @props -Property @{Label="Name"; Expression={$_.Name} },@{Label="ItemPath"; Expression={$_.ItemPath} },@{Label="Notification"; Expression=$scr }
    
  3. So far, so good, correct result items and columns

  4. Click on custom action that start script with command (columns: Name, Updated By, Modified):

    $items | Show-ListView -Modal -Property Name, @{Label="Updated by"; Expression={$_."__Updated By"} }, @{Label="Modified"; Expression={ $_.__Updated.ToLocalTime() } }
    
  5. Items in result are correct, but columns are taken from the first "ListViewResult"

Any idea how to separate this 2 reports to use unique property definition?

Show-ListView

Below is full demo script, called from the Content Editor ribbon.

Should present cloned items for the current item in the list view (dialog 1 in the screenshot below). Working as expected:

function Get-Notifications {
    param($ItemId)      
    $currentItem = Get-Item master: -ID $ItemId 
    $notifications = $currentItem.Database.NotificationProvider.GetNotifications($currentItem)
    $counter = 0
    foreach($notification in $notifications) { $counter++ }
    return $counter
}
function Display-ClonedReport {
    param($SourceItem, $Options)    
    $clonedItems = Get-ItemClone -Item $SourceItem
    $reportItems = New-Object System.Collections.ArrayList      
    $currentItemId = $null
    $currentItemLanguage = $null    
    ForEach ($item In $clonedItems) {   
        if($currentItemId -ne $item.Id) {   
            $currentItemId = $item.Id
            $currentItemLanguage = $item.Language.Name          
            $currentItem = Get-Item master: -ID $item.Id            
            if($currentItem -ne $null) {                            
                $reportItems.Add($currentItem)
            }
        }       
    }   
    $props = @{
        Title = "Cloned Items"
        InfoTitle = "Cloned Items of the Item '$($rootItem.Paths.FullPath)'"
        InfoDescription = "List of cloned Items. Click on item and execute action"
        Icon = "Software/32x32/branch.png"
        PageSize = 25
    }   
    $scr = [scriptblock]::Create('Get-Notifications -ItemId $_.Id')
    $reportItems|   
        Show-ListView -ViewName "MyView" @props -Property `
            @{Label="Name"; Expression={$_.Name} },
            @{Label="ItemPath"; Expression={$_.ItemPath} },         
            @{Label="Notification"; Expression=$scr }           
}
$rootItem = Get-Item -Path .
Display-ClonedReport -SourceItem $rootItem 

Below is demo script, called from the actions ribbon of the first list view result.

For demo purpose, here we try to present only list of languages.

Should display second list view with columns "Updated" and "Modified" (as it is when we call this script in PowerShell ISE), but now, columns are not as it is defined in the script (dialog 2 in the screenshot below). Looks that list view reading columns from the session defined in the first call.

function Notifications-Report {
    param($Item)    
    $items = Get-ChildItem -Path "master:\sitecore\system\Languages"
    $items | Show-ListView -ViewName "MySecondView" -Modal -Property @{Label="Updated"; Expression={$_."__Updated By"} }, @{Label="Modified"; Expression={ $_.__Updated.ToLocalTime() } }
}
Notifications-Report   

enter image description here

Here is screenshot when we call this script in the PowerShell ISE:

enter image description here

  • Any chance you can provide a complete and simple script example that reproduces the issue? Should make debugging easier. – Michael West May 4 at 1:42
  • I edit initial post by adding demo script code, screenshots and more info. – BMM May 4 at 9:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.