We have automated deployment of webs and lists with PowerShell (PnP). We noticed that some of our views have got the "Type" (DocIcon) column visible but we did not script it to include that column in the views.

After some analysis I found out, that the "Type" (DocIcon) column gets added by SharePoint automatically to the default view, as soon as a folder is created.

As we created folders in the lists to break permission inheritance we see this problem occur, as soon as we create the first item (a background mechanism creates a folder for the item with the desired permissions on it).

I tried to solve it, with setting "EnableFolderCreation" to false on the list, but it changed nothing.

Funny thing is, that I even created a folder and an item in it using PnP PowerShell after list creation (they would be deleted afterwards), before we setup the views (without DocIcon). But still, as soon as I create the first item manually, the DocIcon column appeares in the default view. But when I then delete all the folders/items from the list, also remove the DocIcon column from the default view, and then create an item again (with a folder automatically in the background) - the DocIcon column does NOT reappear in the default view.

So I don't understand, why it works the second time, but not the first time when I "manually" create some dummy item/folder to trick the mechanism.

Any ideas to get rid of this SharePoint default behaviour?


After some digging I found out what the problem was. The DocIcon column did not appear on folder creation, it already appeared when toggling "EnableFolderCreation" to "true" - what happened when our background mechanism for the folder (with permissions) creation saw that the flag was "false". Every-time this flag is being toggled on, SharePoint will add this DocIcon column back to the default view. So the solution was, that we set this flag to "true" directly after we create the list instance, so it won't get toggled on (as it already is "on") when the first item is being created:

Set-PnPList -Identity $list -EnableFolderCreation $true

Or in C#

list.EnableFolderCreation = true;
| improve this answer | |

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.