1

how to set up multiple select on the Sitecore PowerShell interactive dialog?

Thanks

2 Answers 2

3

You can write the code something like this. And it will open a prompt in Powershell and show the controls.

$dropDownSelector = Get-Item -Path "master:\content"

$dialogParams = @{
Title = "Dialog title"
Description = "Description under title"
OkButtonName = "Execute"
CancelButtonName = "Close"
ShowHints = $true
Parameters = @(
    @{
        Name = "dropDownSelector"
        Title = "Dropdown Selector"
        Root = "/sitecore/content/"
        Tooltip = "Enter item name or select from tree"
    }
    @{
        Name = "dropTreeSelector"
        Title = "Droptree Selector"
        Editor = "droptree"
        Source = "/sitecore/content"
        Tooltip = "Select from dropdown tree"
    }
)
}

 $dialogResult = Read-Variable @dialogParams

For more information of other field types, please refer this link

https://www.oshyn.com/blog/read-variable-parameters

3

This simple script should do what you need:

$options = [ordered]@{Monday = 1; Tuesday = 2; "Wednesday (Selected)"= 4; Thursday = 8; "Friday (Selected)" = 16; Saturday = 32; Sunday = 64};

$optionsTab = @( 
    @{ Name = "checklistItems"; Title="Multiple options - checklist"; Options=$options; Tooltip="Checklist with various options"; Tab="Options"; Editor="checklist"; ParentGroupId = 2; HideOnValue = "2"; }
)

$allTabs = $optionsTab

$dialogProps = @{
    Title = "Kitchen Sink Demo"
    Description = "The dialog demonstrates the use of all available controls grouped into tabs."
    Width = 650 
    Height = 700
    OkButtonName = "Continue"
    CancelButtonName = "Cancel"
    ShowHints = $true
    Icon = "Officewhite/32x32/knife_fork_spoon.png"
    Parameters = $allTabs
}

$result = Read-Variable @dialogProps

if($result -ne "ok") {
    Exit
}

Write-Host 'Editor checklist: returns an array of string values' -ForegroundColor Green
$checklistItems | Out-Default

There are quite extensive examples of scripts, including building dialogs (this snippet has been taken from "Read-Variable Kitchen Sink" script) that you can base on when building your dialogs.

You can find the scripts in SPE\Training module and the mentioned script in SPE\Training\Misc\Dialogs\Advanced\Read-Variable Kitchen Sink

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy