Problem
When using CSOM via PowerShell, and adding folder type list items, I needed to set also the Name field, a.k.a FileLeafRef field value for the item in order to be able to easily add children to items.Setting FileLeafRef during initial item creation never worked.
Solution
First create the item, and after that change FileLeafRef.$listItemCreationInformation = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$listItemCreationInformation.FolderUrl = "http://site.com/lists/mylist/folder"
$newItem = $list.AddItem($listItemCreationInformation);
$title = "Item title"
$newItem["Title"] = $title
$newItem.Update();
$clientContext.ExecuteQuery()
$newItem["FileLeafRef"] = $title
$newItem.Update();
$clientContext.ExecuteQuery()
No comments:
Post a Comment