locked
Custom View for ALL document libraries. RRS feed

  • Question

  • Hello everyone,

    Currently i'm working on a project in SharePoint Online portal where there are multiple level of sites and subites and in all of them combine there are about 1000 document libraries and i have to change their views.

    So i was wondering is it possible that i create my custom view and apply it to all document libraries otherwise i have to visit each and every document library to modify their view which is very time consuming.

    Thanks in Advance.


    • Edited by Ravi Raghav Thursday, February 18, 2016 6:18 AM
    Thursday, February 18, 2016 6:17 AM

Answers

  • Hi Ravi,

    According to your description, you want to create views for multiple libraries.

    Per my knowledge, it's not possible in OOB way.

    This link seems to give a direction:

    https://smartrider.wordpress.com/2011/08/17/how-to-create-views-programmatically-in-sharepoint-2010/

    You should deploy this as a feature. Once deployed, go to Site Features and activate it. It will be applied to the libraries in the site.

    Best Regards,

    CY


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, February 19, 2016 7:24 AM
  • Add-PSSnapin Microsoft.SharePoint.PowerShell -EA silentlycontinue
    
    
    #Title View
    $viewTitle = "Sort by modified date"
    #Add the column names from the ViewField property to a string collection
    $viewFields = New-Object System.Collections.Specialized.StringCollection
    $viewFields.Add("DocIcon") > $null
    $viewFields.Add("LinkFilename") > $null
    $viewFields.Add("Modified") > $null
    $viewFields.Add("Editor") > $null
    $viewFields.Add("FileSizeDisplay") > $null
    #Query property
    $viewQuery = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE'/></OrderBy>"
    #RowLimit property
    $viewRowLimit = 50
    #Paged property
    $viewPaged = $true
    #DefaultView property
    $viewDefaultView = $false
    
    $ListsToUpdate = @()
    
    $App = Get-SPWebApplication  http://....
    foreach ($Site in $App.Sites)
    {
         foreach ($Web in $Site.AllWebs)
         {
             foreach ($List in $Web.Lists)
             {
              if($List.BaseType -eq "DocumentLibrary" -and $List.Title -eq "Documents" )
              {
                    $ListsToUpdate += $Web.Lists[$List.Title]
              }
             }
         }
    }
    
    
    
    
    foreach($List in $ListsToUpdate) {
        Write-Host $List.Title
        #Create the view in the destination list
        $newview = $List.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)
    }
    


    Miguel Angel

    Friday, February 19, 2016 9:12 AM

All replies

  • Hi

    this is your solution

    https://gallery.technet.microsoft.com/office/How-to-create-a-List-View-fb4782c9

    You should run the function on each site  and library


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Thursday, February 18, 2016 6:48 AM
  • Hi Ravi,

    According to your description, you want to create views for multiple libraries.

    Per my knowledge, it's not possible in OOB way.

    This link seems to give a direction:

    https://smartrider.wordpress.com/2011/08/17/how-to-create-views-programmatically-in-sharepoint-2010/

    You should deploy this as a feature. Once deployed, go to Site Features and activate it. It will be applied to the libraries in the site.

    Best Regards,

    CY


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, February 19, 2016 7:24 AM
  • Add-PSSnapin Microsoft.SharePoint.PowerShell -EA silentlycontinue
    
    
    #Title View
    $viewTitle = "Sort by modified date"
    #Add the column names from the ViewField property to a string collection
    $viewFields = New-Object System.Collections.Specialized.StringCollection
    $viewFields.Add("DocIcon") > $null
    $viewFields.Add("LinkFilename") > $null
    $viewFields.Add("Modified") > $null
    $viewFields.Add("Editor") > $null
    $viewFields.Add("FileSizeDisplay") > $null
    #Query property
    $viewQuery = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE'/></OrderBy>"
    #RowLimit property
    $viewRowLimit = 50
    #Paged property
    $viewPaged = $true
    #DefaultView property
    $viewDefaultView = $false
    
    $ListsToUpdate = @()
    
    $App = Get-SPWebApplication  http://....
    foreach ($Site in $App.Sites)
    {
         foreach ($Web in $Site.AllWebs)
         {
             foreach ($List in $Web.Lists)
             {
              if($List.BaseType -eq "DocumentLibrary" -and $List.Title -eq "Documents" )
              {
                    $ListsToUpdate += $Web.Lists[$List.Title]
              }
             }
         }
    }
    
    
    
    
    foreach($List in $ListsToUpdate) {
        Write-Host $List.Title
        #Create the view in the destination list
        $newview = $List.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)
    }
    


    Miguel Angel

    Friday, February 19, 2016 9:12 AM
  • You can create views in SharePoint using JSOM. 

    It depend on the requirement, You can attached this js snipt in web part.

    http://www.c-sharpcorner.com/blogs/how-to-create-a-view-in-sharepoint-2013-using-csom


    http://www.abdulazizfarooqi.wordpress.com Abdul Aziz Farooqi [BizTalk &amp; SharePoint Consultant] MCPD Web &amp; MCPD SharePoint 2010

    Sunday, February 21, 2016 8:37 AM