3

I have a lot of libraries (100+) on a site I manage. I often need to add views to all or most of those libraries, or at least the active ones (50+).

I've seen attempts to answer this question that involve javascript (I don't know JS and I suspect my IT folks wouldn't allow me to use it if I did), creating entirely new libraries (I don't need MORE), and skipping Designer and just doing it one at a time in the browser (duh!)...

It's difficult for me to imagine there's not a simple way to open the two libraries in Designer and copy it from one to the other... but I haven't been able to find it.

1
  • I have answered this question some time ago. Did the script solve your question? If question is answered please mark as answer. If question is still open please give feedback. Thanks.
    – PhilFancy
    Commented Jul 9, 2018 at 11:24

2 Answers 2

0

Try this PowerShell script.

Needs parameters: SiteURL ListName SourceView DestinationListName TargetView

Function CopyListView()
{ Param( [Parameter(Mandatory=$true)] [string]$SiteURL, [Parameter(Mandatory=$true)] [string]$ListName, [Parameter(Mandatory=$true)] [string]$SourceView, [Parameter(Mandatory=$true)] [string]$DestinationListName,  [Parameter(Mandatory=$true)] [string]$TargetView )


###Get Source List and View

$site = Get-SPSite $SiteURL
$web = $site.openweb()
$list=$web.lists[$ListName]
$view = $list.Views[$SourceView]

###Get Target List
$destinationlist = $web.lists[$DestinationListName]

#Copy the source view
if($view -ne $null)
{
#Get View Fields from Source List
$Viewfields = $list.Views[$SourceView].ViewFields.ToStringCollection()
$viewRowLimit="30"
$viewPaged=$true
$viewDefaultView=$false
$viewQuery="<Where><Eq><FieldRef Name='Document_x0020_Type' /><Value Type='Choice'>Customer Reconciliation</Value></Eq></Where>"

#Crete new view on destination List
$newview = $destinationlist.Views.Add($TargetView, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)

# Console output
write-host "View $($SourceView) Copied Successfully!" -foregroundcolor green
}
else
{
write-host "Could Not find: $($SourceView)!" -foregroundcolor red
}

$web.Dispose()         
$site.Dispose()         
}

If this helps, vote appreciated!

-1

You already have libraries, so you best bet is use the script or manual. Couple of the really good script.

Another option for all new libraries(if you want new) then save as template old library then create the new one from it.

lastly, you can do one by one on each library. Because there is no copy-view thing.

1
  • The link is no longer available.
    – PhilFancy
    Commented Jun 25, 2018 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.