Posts Tagged Document Library

SharePoint Online – Synch is not working


Installed Office 2016 on computers and unable to Synch document libraries


First check the version of OneDrive. Please make sure when press synch, exe should be running OneDrive.exe not groove.exe. If OneDrive.exe is running, please make sure OneDrive sync client must be version 17.3.6674.1021 or higher. If not, please follow steps:

  1. Download and install the preview build of the new OneDrive sync client.
  2. Download and open TeamSiteSyncPreview.reg to enable SharePoint document library sync.
  3. Restart computer
  4. Use Chrome to Synch document library.


Comments (1)

PowerShell Script: Enable and Add Content Type in Document Library


We created content types using power shell script. Now, we need to enable content types and add these content types in the list.


$site = Get-SPSite “url of site collection”

$rootWeb $site.RootWeb

$docLib $rootWeb.Lists[“Shared Documents”]

$customContentTypes “ContentType1,ContentType2,ContentType3”

$docLib.ContentTypesEnabled $true


$customContentTypeArray $customContentTypes.Split(“,”)

foreach($customContentType in $customContentTypeArray)


    $customCT $rootWeb.ContentTypes[$customContentType]




Comments (3)

SharePoint 2007: Last Modified Date of Lists / Document Libraries

Scenario: We need to find the last access / modified date of all document libraries in a site collection.


Following code solved our issue

SPSite spSite = new

SPWeb spWeb = spSite.OpenWeb();

SPListCollection listColl = spWeb.Lists;

DateTime lastModifiedDate;

foreach (SPList list in listColl)


if (list.BaseType == SPBaseType.DocumentLibrary)


lastModifiedDate = list.LastItemModifiedDate;

Console.WriteLine(“Document Library Title:” + list.Title + “\nLast Modified Date:” + lastModifiedDate + “\n\n”);



P.S. Please change BaseType as per your requirement for Lists etc or remove this check all together.

Comments (1)

SharePoint 2007: Remove / Disbale Anonymous Access From Browsing Application Pages / Document Library


We enable anonymous access of one of our site collections. The concern was that anonymous users were able to access application pages of the site. Like anonymous users were able to browse “All Site Contents” by adding “_layouts/viewlsts.aspx” to the URL. This also give them ability to browse document libraries, lists etc.


First solution is in two steps:

  1. Enable LockDown Feature using command:

    stsadm –o activatefeature -filename ViewFormPagesLockdown\feature.xml –url <SiteCollectionURL>

  2. Disbale and enable anonymous access by setting it to “Nothing” and then again back to “Entire Web Site”.

Second solution is add following lines in web.config where <location=path…> exist:

<location path=”_layouts/viewlsts.aspx”>



              <deny users=”?” />




This will block user to view “View All site Contents”.

One interesting point is that if you want to search how many SharePoint site are there with this issue, try google “This system library was created by the Publishing feature to store pages that are created in this site.”


Comments (2)

Event Handler to Synchronize (Populate Data) List / Document Library Columns Form Other Document Library / List Columns

We have created a solution for one of our clients. The solution is based on uploading documents and attaching workflows with the documents.

Uploaded documents have different columns describing the document’s meta data. Our clients’ wants that these column in the task list.

We decide to write two event handlers. One was against the list and other was against the document library.

The event handler against list runs when a task is created in the task list. It fetches the information from the desired columns in the document library and populates the columns in the task list row.

The code is:

 public class MyClass : SPItemEventReceiver    {       

public override void ItemAdded(SPItemEventProperties properties)        {           

SPListItem item = properties.ListItem;                       

SPFieldUrlValue MyURL = null;           

SPView DefaultView = null;           

SPQuery SelectQuery = null;           

SPListItemCollection SelectedDoc = null;            

string URLText = null;           

string URL = null;                        

SPWeb site = (SPWeb)properties.OpenWeb();           

SPList DocLib = site.Lists[“Document Library Name”];                

MyURL = new SPFieldUrlValue((string)item[“Link”]);           

URL = MyURL.Url; URLText = URL.Substring(URL.LastIndexOf(‘/’) + 1);         

DefaultView = DocLib.DefaultView;            

SelectQuery = new SPQuery(DefaultView);            

SelectQuery.Query = “<Where><Eq><FieldRef Name=’FileLeafRef’/><Value Type=’Text’>” + URLText + “</Value></Eq></Where>”           

SelectedDoc = DocLib.GetItems(SelectQuery);  

foreach (SPListItem doc in SelectedDoc) // run for once            {                  

item[“Col 1”] = doc[“Col 1”];                 

item[“Col 2”] = doc[“Col 2”];                 

item[“Col 3”] = doc[“Col 3”];                 






The second event handler was written against the document library for synchronization purpose. If user changes / update the data in the document library column, these changes must be reflected in the task list column. The event handler capture and runs against the update vent.

The code is:

 public class MYClass1 : SPItemEventReceiver    {       

public override void ItemUpdated(SPItemEventProperties properties)        {            

string DocName = null;           

string DocTitle = null;            

SPView DefaultView = null;           

SPQuery SelectQuery = null;           

SPListItemCollection SelectedDoc = null;                       

SPListItem doc = properties.ListItem;           

SPWeb site = properties.OpenWeb();           

SPList TaskList = site.Lists[“Task List Name”];            

DocName = doc[“Name”].ToString();                       

DocTitle = DocName.Substring(0,DocName.LastIndexOf(‘.’));            

DefaultView = TaskList.DefaultView;            

SelectQuery = new SPQuery(DefaultView);             

SelectQuery.Query = “<Where><Eq><FieldRef Name=’LinkTitle’/><Value Type=’Text’>Please approve “ + DocTitle + “</Value></Eq></Where>”           

SelectedDoc = TaskList.GetItems(SelectQuery);            

foreach (SPListItem task in SelectedDoc)             {               

task[“Col 1”] = doc[“Col 1”];               

task[“Col 2”] = doc[“Col 2”];               

task[“Col 3”] = doc[“Col 3”];               






In this way, changes in the columns of document library will be immediately visible in the columns of task list as well.  

In case you don’t know how to create and deploy event handler, follow this link.

Comments (8)

Local Copy of Document Library (Available Online Only)

Creating a local copy of document library is simple and same as adding a network place on your machine. 

The steps are very simple. Click on “My Network Place” icon on your desktop and then, click on “Add Network Place”. This will open a new wizard “Welcome to Add Network Place Wizard”. Click “Next” and it will take some seconds to download information from internet. Select “Choose another network location” and click “Next”. A text box will appear with the text caption “Internet or network address”. 

Copy the URL of the document library for which you want to create a local folder. This can be done by right click on the document library and selecting “Copy Shortcut”. 

Paste that shortcut in the “Internet or network address” and click “Next”. The wizard will ask you the name of the local folder on your machine. Type the name of your choice and click “Next”. A confirmation window will appear with the message of successful creation of the network place. Click “Finish” and folder will be created.  

You can copy and paste your documents in the local folders and documents will be automatically uploaded to the site document library. Any change that you make in the local folder will be reflected in the document library.

P.S. local folder will be available when you are online. Nothing will be availabe when offline.

Comments (3)