Ribbon missing on SharePoint List or Library page SharePoint 2013

This article is related to below post where user reported missing ribbon issue after migration from SharePoint 2007 to 2013 version.

https://social.technet.microsoft.com/Forums/en-US/628b9f7b-b1e7-4bb1-b01d-fcb11b252862/ribbons-missing-after-migration

Scenario:

Ribbon not visible on SharePoint List/Library page load. Mostly reported after site migration from 2007 to 2010/2013 version. Also if you have added a content editor web part on this page.

RibbonMissing

01.<scripttype="text/javascript"src="https://code.jquery.com/jquery-1.11.3.min.js "></script>
02.<scripttype="text/javascript">
03.$(document).ready(function(){
04.var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
05.           if(elem != null) {
06.                var dummyevent = new Array();
07.                dummyevent["target"] = elem;
08.                dummyevent["srcElement"] = elem;
09.                WpClick(dummyevent);
10.                _ribbonStartInit("Ribbon.Browse", true)
11.            }
12. });
13.</script>
Advertisements
Advertisements

Copy sharepoint views to other libraries powershell

[CmdletBinding()]

Param
(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$WebURL,
[Parameter(Mandatory=$true)][string]$SourceList,
[Parameter(Mandatory=$true)][string]$SourceView,
[Parameter(Mandatory=$false)][string]$NewViewName,
[Parameter(Mandatory=$false)][string]$TargetURL,
[Parameter(Mandatory=$false)][string]$IgnoreLibs,
[Parameter(Mandatory=$false)][string]$AsDefault,
[Parameter(Mandatory=$false)][string]$OutputPath,
[Parameter(Mandatory=$false)][string]$SmtpServer,
[Parameter(Mandatory=$false)][string]$EmailFrom,
[Parameter(Mandatory=$false)][string]$EmailTo
)

Function Copy-SPView
{

Write-Host &quot;Loading Sytem Modules &quot;
Get-Module -listAvailable | import-module

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Write-Host &quot;Loading Sharepoint Module &quot;
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell) -eq $null )
{
Write-Host &quot;Failed to load sharepoint snap-in. Could not proceed further, Aborting …&quot;
Exit
}
}

Start-SPAssignment -Global

$SPWeb  = Get-SPWeb -Identity $WebURL -ErrorAction SilentlyContinue
$SPWebT = Get-SPWeb -Identity $TargetURL -ErrorAction SilentlyContinue

$ignoreList = &quot;Customized Reports&quot;,&quot;Form Templates&quot;,&quot;Shared Documents&quot;,&quot;Site Assets&quot;,&quot;Site Pages&quot;,&quot;Style Library&quot;,&quot;Master Page Gallery&quot;,&quot;Picture&quot; + $SourceList + $IgnoreLibs

if($SPWeb -eq $null){ Write-Host &quot;Unable to reach the provided URL, Aborting …&quot; ;Exit }
if( ($SPWeb.Lists.TryGetList($SourceList) ) -eq $Null){ Write-Host &quot;The list $SourceList is not availible, Aborting …&quot;; Exit }
if($AsDefault -ne $True){$AsDefault = $False}

$SourceLists=$SPweb.lists[&quot;$SourceList&quot;]

if( ($SourceLists.Views[$SourceView]) -eq $Null ){ Write-Host &quot;The view $SourceView does not exist, Aborting …&quot;; Exit  }
if($NewViewName -lt 1){ $NewViewName = $SourceView }

Go through each document library in the target site

$listIds = @();
$i = 0;

if($SPWebT -ne $null)
{
$lists=$SPWebT.lists
}
else
{
$lists=$SPWeb.lists
}

while ($i -lt $lists.Count)
{
$list = $lists[$i]

if($list.BaseType -eq &quot;DocumentLibrary&quot;)
{
if ($Ignorelist -contains $list.Title)
{
write-host $list &quot;is Ignored&quot; -foregroundcolor Yellow -backgroundcolor Black
}
else
{
$view = $list.Views[$NewViewName]
if ($view -ne $null)
{
Write-Host &quot;Updating existing view&quot; -foregroundcolor Yellow -backgroundcolor Black

$list.views.delete($view.ID)
$list.update()
}

$Viewfields = $Sourcelists.Views[$SourceView].ViewFields.ToStringCollection()
$viewRowLimit=&quot;100&quot;
$viewPaged=$true
$viewDefaultView=$AsDefault

Setting the Query for the View

$viewQuery = $Sourcelists.Views[$SourceView].Query
$viewName = $NewViewName

Finally – Provisioning the View

try
{
$myListView = $list.Views.Add($viewName, $viewFields, $viewQuery, 100, $True, $False, &quot;HTML&quot;, $False)
}
catch
{
Write-Host &quot;Not all columns are availible in the target library&quot; -foregroundcolor Yellow
}

You need to Update the View for changes made to the view

Updating the List is not enough

$myListView.DefaultView = $AsDefault
$myListView.Update()
$list.Update()

Write-Host &quot;$viewName added to Library $list&quot;
}
}
$i = $i + 1
}
$SPWeb.Dispose()
}

Copy-SPView ($WebURL,$SourceList,$SourceView,$NewViewName)

Using this script it’s possible to copy views from a source library to any target library.
This includes copying views to libraries in other site collections / web applications or even other SharePoint servers!

Summary of possible variables:

– WebURL
URL of the source library
– SourceList
Displayname of the source library what contains the view
– SourceView
Name of the view that needs to be copied
– NewViewName
Name of the view in the target libraries. (if left empty the source view name will be used.)
– TargetURL
URL of the target site / site collection of web application (If left empty the libraries in the WebURL are being
updated)
– IgnoreLibs
Name of the libraries that need to be ignored.
(The script contains a list of SharePoint Household Libraries
that are ignored by default including the Source Library.)
“Customized Reports”,”Form Templates”,”Shared Documents”,”Site Assets”,”Site Pages”,
“Style Library”,”Master Page Gallery”,”Picture”

.Example 1

This example copies the view to all document libraries within the source URL

PS C:> .Copy-SPView.ps1 -WebURL <source URL> -SourceList <Your Source Library> -SourceView <Name of View>

.Example 2

This example copies the view to all document libraries within the target URL.

PS C:> .Copy-SPView.ps1 -WebURL <source URL> -SourceList <Your Source Library> -SourceView <Name of the View> -TargetURL “<Your target URL>”

.Example 3

This example shows all possible variables that are currently working.

PS C:> .Copy-SPView.ps1 -WebURL <source URL> -SourceList <Your Source Library> -SourceView <Name of the View> -TargetURL “<Your target URL>” -NewViewName “Rogier’s View” -IgnoreLibs “Shared Documents”

Please let me know if this was helpful