Can any please explain me how to add multiple items to the multilist field. For me only last item is getting selected.

$allItems = Get-ChildItem -Path '/sitecore/content/ListManagerTask' -Recurse
foreach($multilistItem in $allItems) { $item[$templateField.Name] += $multilistItem.ID; } 
$item.Editing.EndEdit() | Out-Null`

I want to assign all items in $allItems to multilist.

This is how i'm getting


You haven't added any | character to split the IDs of selected items. This works:


$allItems = Get-ChildItem -Path '/sitecore/content/ListManagerTask' -Recurse

foreach($multilistItem in $allItems) { 
    if (![string]::IsNullOrEmpty($item[$templateField.Name])) {
        $item[$templateField.Name] += "|";
    $item[$templateField.Name] += $multilistItem.ID.ToString()

$item.Editing.EndEdit() | Out-Null
  • 1
    There are some code snippets which include working with multilist here doc.sitecorepowershell.com/code-snippets Jul 12 '19 at 13:28
  • Thank you so much sir...Its working fine... Jul 12 '19 at 13:42
  • @kohilavani I'm glad it worked. If you find this answer useful, you should mark it as correct. Upvoting is also encouraged. Jul 12 '19 at 13:47
  • 1
    Wow -- I was just looking for the same thing today... I found it more efficient to build the string and then do the assignment once rather than continuously editing the item
    – Mike
    Jul 12 '19 at 15:06
  • Item is edited only once. It's the field value which is updated multiple times. But you're right. It could be more efficient to build the string first and then assign it to the field value. Jul 12 '19 at 15:59

Your Answer

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

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