Thursday, May 08, 2014

Hide/Show Underscore (_) Folders in Explorer Viewer using (JSOM/REST) in LisItem PropertyBags

Today's case is about a Out of Box SharePoint behavior that some of you probably already face in your daily work using the Enterprise Content Management and Folders.

When end users creates folders in document Library and name they added the Folder Name started with underscore (_). After the creation they continue to work adding new Documents to that folder, but when they open the Document Library using Explorer Viewer are not able to see the Folder with "_" in the beginning, what causes some panic when they have to manage a huge volume of documents.

There is a very nice article talking about this behavior and reason but they only reference some Powershell IT task in the SPFarm.

The article don't take in consideration multiple scenarios like consultants that don't have access to Farm or they are working with SharePoint 2010 Client API, this API don't allow to access "PropertyBag" SharePoint Objects in Lists, but there is a workaround for SharePoint 2010, that is explained in this article, or how users can manage this property using cloud "Office365" or SP2013. 
The SP2013/Office365  have the ability to change the Lists PropertyBag SharePoint Object using REST or JSOM for this case the option "vti_winfileattribs" .

This propose solution works using SharePoint JavaScript Object Model (JSOM) in SharePoint 2010, SharePoint 2013 and Office 365 in away we can manage the visibility of underscore Folders in Explorer Viewer.

For this example i create folder with a name wish has underscore (_) in the begin.

When you open the Explorer Viewer you are not able to see the Folder "_".

One way to update this properties could be using the F12 (Developer Tools) option of your Internet Explorer and the console to execute some JSOM Code as show in the image.

Show underscore Folder using PropertBag Listitem

The following code updates the Columns MetaInfo with the Property bag "vti_winfileattribs"  and Parameter "null" associated to show the Folder from the explorer Viewer. 

//update ListItem Metainfo
function updateListItem() {
    var clientContext = new SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('Documents');
    this.oListItem = oList.getItemById(30);//ID of Listitem
    clientContext.executeQueryAsync(Function.createDelegate(thisthis.onQuerySucceeded), Function.createDelegate(thisthis.onQueryFailed));
function onQuerySucceeded() {
    alert('Item updated!');
function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


After the code is executed the column PropertyBag "MetaInfois updated with the new value.

You can see the PropertyBag "Metainfo" content of the ListItem using the following Tool with the new value.


After the change is dont you should be able to see the Folder "_MyFolder"

Hide underscore Folder using PropertBag Listitem

The following code updates the Columns MetaInfo with the Property bag "vti_winfileattribs"  and Parameter "00000016"associated to hide the Folder from the explorer Viewer. 

//update ListItem Metainfo
function updateListItem() {
    var clientContext = new SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('Documents');
    this.oListItem = oList.getItemById(30); //ID of Listitem
    oListItem.set_item('MetaInfo', 'vti_winfileattribs:SW|00000016');
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded() {
    alert('Item updated!');
function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


You can see the PropertyBag "Metainfo" content of the ListItem using the following Tool with the new value.


After the change is done the folder should not appear in the Explorer Viewer as shown in the image.

The hard in this topic was the SharePoint 2010 Environment, the Client Object Model don't allow  access PropertyBags but allows to access the Columns MetaInfo that uses Lookup for the PropertyBags Objects and that makes the trick.

Support Link:

Done, very simple solution that could avoid some headaches.

Hope you like this article,
Kind regards,

André Lage

No comments: