Wednesday, October 17, 2012

Slideshow views in Picture Libraries are not allowing end users to delete images


Hello Readers,
Recently I came across an issue in my project where the end users are not able to delete pictures in Picture Library of a SharePoint site which is migrated from 2007 to 2010.
The problem is with the view for the library, not the library itself as the pictures are there and can be opened if I open the library in Windows Explorer.  If I create a new view for the library, the new view works correctly.  If I try to modify the view for the library and then return to the library, I can no longer navigate to subfolders the display only shows the root folder of the picture library.
Here are the steps of what we need to do.
  1. Clone the view "All Pictures" to a view called "Temp" and assigned Temp to be the default view.
  2. Delete the "All Pictures" view
  3. Clone the view "Temp" to "AllItems" assigning AllItems to be the default view.
  4. Delete the view "Temp"
  5. Set  the title fo the AllItems view to be "All Pictures"
Aside from the view GUID everything appears to be identical, but with the links functioning properly.
Here is the below script :
filter Get-Web {
$_.AllWebs
}
Filter get-List {
$_.Lists
}
$viewtitle = 'Slide show view'
$viewinternaltitle = 'Slidshow'
$listtitle
$lists = get-SpSite | Get-Web | Get-List | where-object{$_.basetemplate -eq 'PictureLibrary'} | where-object {$_.title -eq 'BannerImages'}
foreach ($list in $lists){
foreach($view in $list.views){
if($view.title -eq $viewtitle){
$view.clone('Temp',$view.RowLimit,$view.Paged,$view.DefaultView)
$viewid1 = $view.id
}
$list.views.Delete($viewid1)
$list.update()
}
}
foreach ($list in $lists){
foreach($view in $list.Views ){
if($view.title -eq 'Temp'){
$view.clone($viewinternaltitle, $view.rowlimit,$view.paged,$view.defaultview)
$viewid2= $view.id
}
}
$list.views.Delete($viewid2)
$list.update()
}
foreach ($list in $lists){
foreach($view in $list.views) {
if($view.title -eq $viewinternaltitle){
$view.title = $viewtitle
$view.update()
$view.title
break
}
}
}

No comments:

Post a Comment