pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Document set added with Add-SPODocumentSet appears as folder in modern document library view #644

Open CatoAntonsen opened 7 years ago

CatoAntonsen commented 7 years ago

Reporting an Issue or Feature

It's an issue, but not 100% sure where the problem lies.

Expected behavior

Running Add-SPODocumentSet -Name "Test document set" -List "Test list" -ContentType "Documentsett" (NB! Content type is the Norwegian name for "Document Set".

A document set should be created and I should be able to click it to view the welcome page with the properties and documents.

Actual behavior

The document set that is created looks like an folder with an folder icon. The content type is correct (Dokumentsett). If I click this folder, I go into the empty folder instead of seeing the document set welcome page.

This only happens when modern view is enabled on the library. If I enable classic view, the behavior is as expected.

The strange thing is that if I manually create the document set (with modern view enabled), it created correctly. So there is "something" different when creating using the PowerShell command.

Steps to reproduce behavior

  1. Create a document library (with modern document library view enabled)
  2. Enable content types on the library
  3. Add Document Set as content type (optionally remove existing Document content type)
  4. Run: Connect-SPOnline -Url $url -Credentials (Get-Credential) Add-SPODocumentSet -Name $title -List $listName -ContentType "Dokumentsett"
  5. Notice that the newly created document set has a folder icon and appears as an folder when you click it.

I've not included the variable names as they would vary. The name of the content type is in Norwegian and you might have to change that.

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)

2.10.1612.0

How did you install the PnP-PowerShell Cmdlets?

Pieter-Veenstra commented 7 years ago

If it helps, I've created document sets using Add-PnPListItem/Add-SPOListItem in the past and I found that it worked.

CatoAntonsen commented 7 years ago

@Pieter-Veenstra, did you manage to add a Document Set to a document library? I get an error message saying I have to "... use SPFileCollection.Add()"

owenmorris commented 7 years ago

I am seeing the same issue. When I get the list item for the newly created document set, the symptoms I am seeing is that the HTML_x0020_File_x0020_Type field is set to SharePoint.DocumentSet as expected but this is not reflected in the ProgId field. The content type is set correctly.

When I create a document set manually in SP Online, the ProgId field is also set to SharePoint.DocumentSet. The ProgId field is read only via the CSOM.

CatoAntonsen commented 7 years ago

I noticed the same thing happen when I create the document set using CSOM in PowerShell:

[Microsoft.SharePoint.Client.DocumentSet.DocumentSet]::Create($ctx, $folder, $projectname, $ct.Id) 
$ctx.ExecuteQuery()
PetriAsi commented 7 years ago

@CatoAntonsen , Did you find reason for this issue or workaround for modern views? @ovenmorris I see that changing HTML_x0020_File_x0020_Type is reflected to ProgId on item.

bobtheslob commented 6 years ago

While this is old and the cmdlet names have changed, the behavior hasn't. If anyone else runs across this, I was able to work around it by grabbing the ContentType off the library first, then using it as an argument as such: $ct = Get-PnPContentType -List 'Documents' -Identity 'Document Set' Add-PnPDocumentSet -List 'Documents' -ContentType $ct -Name 'SetName'

Hope this helps someone...

PeterHeibrink commented 6 years ago

Thanks @bobtheslob, worked for us.

NPrice99 commented 6 years ago

Hi @bobtheslob creating the document set this way works (it did not work before I tried this), but I get 404 file not found when I try and access the document set.

Riftsan commented 6 years ago

@bobtheslob this works! Thank you

KoenZomers commented 6 years ago

I ran into this issue as well. The workaround of @bobtheslob does work, but it needs to work intuitively without having to know this workaround. I've submitted PR https://github.com/SharePoint/PnP-PowerShell/pull/1632 in which this will work without any workarounds so this issue can be closed once it gets merged.

tanwedar commented 5 years ago

Thanks @bobtheslob! I had pretty much the exact thing except I was missing -List on my Get-PnPContentType line. That made all the difference between a folder and a document set being created.

KoenZomers commented 5 years ago

@tanwedar you still encountered this issue with a recent version of PnP PowerShell which included my PR?

tanwedar commented 5 years ago

Correct, it was happening earlier this week and this morning was when I saw @bobtheslob's post. I can pull once again if you want.

KoenZomers commented 5 years ago

@tanwedar, that's funny as I thought I managed to fix it. Can you provide the exact PowerShell commands you used when it went wrong?

tanwedar commented 5 years ago

Of course. As far as I can remember was the same exact as when it went right, except the -List.

$ct = Get-PnPContentType -Identity "<content type>" vs $ct = Get-PnPContentType -Identity "<content type>" -List "<list>"