Pages

Showing posts with label Documents. Show all posts
Showing posts with label Documents. Show all posts

Monday, November 6, 2017

List all “Docs I'm following” in Office 365 | SharePoint Online | OneDrive for Business

Introduction
We can follow documents in a SharePoint online. So that all the documents we follow will be referenced in OneDrive for business; which leads to easy access.
Problem
Till today, there no navigation option available to see all the following document in Modern Experience.
image
Solution
To over come it you have to switch to Classic OneDrive (See the above image and click on the text highlighted in yellow).
Now you can see a new navigation option added on the left as ‘Followed”.
Click it and you can see the documents you are following.
image


Thursday, January 23, 2014

Enable auditing for a specific content type through "Content Type Policy Templates" in SharePoint Online | SharePoint 2013

Introduction

Recently our client project had a requirement where a document type (or a content type) should be audited for its events such as editing items and checking in and checking out items, and also the policy should be reusable for other content type when we need. When I consult my architect he in instruct me how to do it. So I thought to share how I did this.

Solution
  • First of all you have to create a policy. 
    • To create Go to Site Setting -> Select Content Type Policy Templates (under Site Collection Administration category).
    • There select Create. The Url will end with “_layouts/15/policyconfig.aspx”.
    • Create a policy as you need. As per to my requirement I need an auditing policy. I created a policy enabling Auditing by selecting Enable Auditing option – Please refer the screenshot given below.

  • Then Select the content type which you should enable auditing. You can select the content type by going to Site Setting -> Click Site content types (under Web Designer Galleries) -> Select the content type you wish to add the policy.
    • In case you don’t have a content type; to create go to Site Setting -> Click Site content types (under Web Designer Galleries )
    • Select Create option on the top and create a content type as you need.
  • Select the “Information management policy settings” under setting.
  • You will see something like this.
  • There select “Use a site collection policy:” (the 3rd option) and select your policy name and click OK.
  • Now you have associated the auditing policy with the content type. 
  • Your logs reports can be seen under Go to Site settings -> Site Collection Administration -> Audit log reports.

Conclusion

You can also create a new policy at the Content Type -> Information management policy settings. But this will applicable only for the specific content type and you cannot be reusable for other content types; simply its a content type policy and not a site collection policy.



Thursday, August 22, 2013

Create "Shared with Everyone" folder in Sky Drive Pro / Documents library - SharePoint 2013

Introduction

As I mentioned in my previous post our team faced issues in document migration from SharePoint 2010 to SharePoint 2013. The actions were not as expected.

Problem Background

In some profile we couldn't find "Shared with Everyone" which folder is having "Read" permission to "All Authenticated Users". So we created a console application which will create "Shared with Everyone" folder and set the permission as we needed.

Solution

Please pass your personal site (spWeb) to the method.

   
 public static void CreateSharedFolder(SPWeb web)
 {

    SPList list = (SPDocumentLibrary)web.Lists["Documents"];
    //Get the folders inside Documents library
    SPFolderCollection folders = web.GetFolder(list.RootFolder.Url).SubFolders;
    List<string> folderList = new List<string>();
    //Add the SPFolderCollection to a generic list
    foreach (SPFolder folder in folders)
    {
        folderList.Add(folder.Name);
    }
    //Check whether folder list has shared with everyone folder
    if (!folderList.Contains("Shared with Everyone"))
    {

       //Create folder inside Documents library 
       folders.Add("Shared with Everyone");

       //Greate users
       SPUser allUser = web.EnsureUser("NT AUTHORITY\\authenticated users");
       //Get folder
       SPListItem item = list.Folders[0];
       if (!item.HasUniqueRoleAssignments)
           item.BreakRoleInheritance(true);

       SPRoleAssignment roleAssignment = new SPRoleAssignment(allUser);
       SPRoleDefinition roleDefination = web.RoleDefinitions["Read"];
                //Add role assignment
       roleAssignment.RoleDefinitionBindings.Add(roleDefination);
       item.RoleAssignments.Add(roleAssignment);
       web.AllowUnsafeUpdates = true;
       item.Update();
       web.AllowUnsafeUpdates = false;

    }

}
 
 


Conclution
Now you can see "Shared with Everyone" folder inside SkyDrive pro.

Thursday, August 15, 2013

Move (Personal) Documents into SkyDrive Pro after migrating from SharePoint 2010 to SharePoint 2013

Introduction

If you have working on migrating SharePoint 2010 personal sites to SharePoint 2013 personal sites;  documents migration may become a headache. The expectation of the action is
"The Personal and Shared document libraries in SharePoint Server 2010 are combined into the SkyDrive Pro document library on the user's My Site in SharePoint Server 2013. Items from the Shared folder are stored in the Shared with Everyone folder in SharePoint Server 2013. Items from the Personal folder are stored at the root of the SkyDrive Pro document library and only shared with the owner of the My Site." - MicroSoft

Problem Background

But in our case, the documents didn't shift under SkyDrive but they were seen under site contents as another document library.

So I wrote a console application to move all the documents to SkyDrive. Here I'm presenting a simple code snippet which you have to modify to use other document library and sub folders under document library. 

Solution 

private static void MovePersonalDocuments(SPWeb web)
{
 SPFolder folder = web.GetFolder("Personal Documents");
 SPFileCollection collFile = folder.Files;
 ///*Copy the files to a generic List of type SPFile*/
 List listFiles = new List(collFile.Count);
 foreach (SPFile oFile in collFile)
 {
  listFiles.Add(oFile);
 }
 SPList list = (SPDocumentLibrary)web.Lists["Documents"];
 for (int i = 0; i &lt; listFiles.Count; i++)
 {
    SPFile movefile = collFile[0];
    Console.WriteLine("Moving File: " + movefile.Name);
           web.AllowUnsafeUpdates = true;
    byte[] fileBytes = movefile.OpenBinary();
    string destUrl = list.RootFolder.Url + "/" + movefile.Name;
    movefile.MoveTo(destUrl, true);
           web.AllowUnsafeUpdates = false;
   Console.WriteLine("Success");
 }
}

Conclusion 

  • Please note that I have only considered moving Personal Documents.
  • The code will help to move Shared Documents and Sub folders as well.